home *** CD-ROM | disk | FTP | other *** search
/ MACD 5 / MACD 5.bin / workbench / tools / czesc_1 / amiga_binaries / fudgit.help < prev   
Text File  |  1993-12-16  |  120KB  |  3,728 lines

  1. ?
  2.  
  3.    F U D G I T   Version 2.33
  4.  
  5.  The three different modes are accessed by commands: 'fmode', 'pmode'
  6.  and 'cmode'. All fmode commands can be abbreviated down to 2
  7.  characters. Vectors have upper case name and scalar variables lower
  8.  case. A mix of both upper and lower cases results in forming a string
  9.  variable. Read the "Intro" help topic for an overview. See the
  10.  "README" help item for complete copyrights.
  11.  
  12.  Send bugs or comments to <isaac@physics.mcgill.ca>.
  13.  
  14. ?Intro
  15.  
  16.  FUDGIT is a double-precision multi purpose fitting program.
  17.  It can manipulate complete columns of numbers in the form
  18.  of vector arithmetic. FUDGIT is also an expression language
  19.  interpreter understanding most of C grammar except pointers.
  20.  It supports all functions from the C math library. Finally,
  21.  FUDGIT is a front end for any plotting program supporting
  22.  commands from stdin. It is a nice mathematical complement
  23.  to GNUPLOT, for example.
  24.  
  25.  The main features of FUDGIT are:
  26.     - Command shell including history;
  27.     - Possible abbreviation of all the ``fitting mode'' commands;
  28.     - Possible plural when it makes sense too;
  29.     - Interactive shell supporting flow control (while,
  30.       if-else-endif, foreach);
  31.     - User definable macros;
  32.     - User definable aliases;
  33.     - On-line help;
  34.     - On-line loadable procedure- or function-objects;
  35.     - On-line selectable plotting program;
  36.     - Fourier transforms;
  37.     - Smoothing;
  38.     - Double-precision built-in calculator;
  39.     - Built-in interpreter supporting most of C language including
  40.       flow control (if, else, while, for, break, continue);
  41.     - User definable functions and procedures;
  42.     - Double-precision vector arithmetic;
  43.     - Access to the complete C math library;
  44.     - Built-in fitting series such as:
  45.         + power series (polynomial);
  46.         + sine series;
  47.         + cosine series;
  48.         + Legendre polynomials;
  49.         + series of Gaussians;
  50.         + series of exponentials;
  51.     - User definable fitting functions;
  52.     - Totally dynamical allocation of variables and parameters;
  53.     - Possible selection of fitting ranges;
  54.  
  55.  FUDGIT has a collection of fitting routines including:
  56.     - straight line (linear) least squares;
  57.     - straight line (linear) least absolute deviation;
  58.     - general linear least squares using QR decomposition;
  59.     - general linear least squares using singular value decomposition;
  60.     - nonlinear Marquardt-Levenberg method;
  61.  
  62.  Refer to the ``User's Manual'' for a complete description and a
  63.  tutorial on I/O and fitting.
  64.  
  65.  See also:
  66.       Modes, C, cmode, fmode, pmode, fit, set, read, save, let
  67.  
  68. ?Modes
  69.  
  70.  FUDGIT is composed of three different modes. These modes can be
  71.  thought of as a C-shell like interpreter linked with a calculator,
  72.  sharing the same variables in memory, and with a plotting program of
  73.  our choice.
  74.  
  75.  The C-shell like interpreter is called the ``fitting mode''. It is
  76.  the central mode and is the one from which all accesses to the disk
  77.  are done. This mode has a range of commands allowing the user to read
  78.  vectors from or save vectors to a data file, to read a command script,
  79.  save the command history, do a Fourier transform of a vector, make a
  80.  linear or nonlinear least square fit, etc... This mode also allows the
  81.  user to define macros and aliases, and to perform plotting-fitting
  82.  batch processes by using some of the built-in flow control commands
  83.  (while, foreach, if-else-endif). All the commands in the fitting mode
  84.  can be abbreviated. It is worth mentioning that in the fitting mode
  85.  the command line parsing is done by analyzing words separated by one
  86.  or more blanks (space or tab), as in an interactive csh.
  87.  
  88.  The ``C-calculator mode'' is a language interpreter supporting most of
  89.  C grammar except pointers. It also supports the complete
  90.  double-precision C math library. Thus, recognized keywords cannot be
  91.  abbreviated, and the different tokens need not be separated. Most of
  92.  the C operators and keywords are understood and a few extra operators
  93.  have been added. This mode does essentially all the possible
  94.  calculations on variables or vectors. Functions and procedures can be
  95.  defined. String variables, string comparison, addition, subtraction
  96.  are also supported by C-calculator mode. This mode is accessed by the
  97.  command `cmode'.
  98.  
  99.  Finally, the ``plotting mode'' is a channel talking directly to the
  100.  plotting program of your choice. Therefore, FUDGIT can serve as a
  101.  front end to any plotting program able to accept input from stdin.
  102.  This way, vectors can be build from the calculator and then plotted by
  103.  your favorite plotting program. The default plotting program is
  104.  GNUPLOT.
  105.  
  106. ?&
  107.  
  108.  The `&' operator forces FUDGIT to use the built-in following fitting
  109.  mode command and to ignore any existing macro or alias with the same
  110.  name. This can be useful in constructions like:
  111.  
  112.     macro cd 1
  113.         pmode cd "$1"
  114.         &cd $1                  # The built-in cd
  115.     stop
  116.  
  117.  See also:
  118.      macro, cd
  119.  
  120. ?\
  121.  
  122.  If anywhere in the middle of a line, a `\' will indicate
  123.  FUDGIT to take the following character as is. If at the end of a
  124.  line, a `\' indicates that the present line continues on the
  125.  following one, and thus to ignore the following carriage return.
  126.  
  127.  See also:
  128.      line editing
  129.  
  130. ?!
  131.  
  132.  Any line beginning with the so-called bang operator `!' will execute
  133.  the system command line with a Bourne shell. Aliased commands as found
  134.  in your interactive C-shell do not hold any more. For example,
  135.  commands like `!rm' will not be interactive (i.e. /bin/rm -i) even
  136.  if you have such an alias in your ".cshrc" file. Be careful!  A
  137.  nice turnaround is to alias rm to ``! rm -i'' in your 
  138.  ".fudgitrc" file and to use the `rm' command directly from
  139.  FUDGIT's shell.
  140.  
  141.  When used in a macro name or an alias name, the `!' character has
  142.  still another meaning. This tells the parser that characters following
  143.  the `!' are optional. Therefore, if one types the following,
  144.  interactively, (see NOTE)
  145.  
  146.      set noexpand
  147.      alias da!te !date
  148.      set expand
  149.  
  150.  then the parser will recognize `da', `dat' and `date' as
  151.  all synonymous to the system command `! date' run through a Bourne
  152.  shell.
  153.  
  154.  NOTE: In interactive mode, the history functions will try to interpret
  155.  a history substitution if the `!' is not followed by a space. See the
  156.  appendices. To avoid that the line be scanned for a history event
  157.  designator, use the `set noexpand' command. In some cases, it
  158.  might be simpler to use the `system' command.
  159.  
  160.  Syntax:
  161.      !"command"
  162.  
  163.  Example:
  164.      ! mail
  165.  
  166.  See also:
  167.      alias, ls, vi, foreach, system, set expand
  168.  
  169. ?help?
  170.  
  171.  A question mark will indicate FUDGIT to try to get the possible
  172.  options available to the command presently typed. This kind of help is
  173.  context sensitive and works when an insufficient number of arguments
  174.  is supplied. The question mark also serves as a wild character in
  175.  string subtraction.
  176.  
  177.  Syntax:
  178.      "command" ?
  179.  
  180.  Examples:
  181.      ?
  182.      show ?
  183.      set function ?
  184.  
  185.  See also:
  186.      help, strings
  187.  
  188. ?$
  189.  
  190.  The `$' operator expands scalar variables or constants (double
  191.  precision numbers from C-calculator mode lookup table) as well as
  192.  string variables or constants. Existing scalar variables can thus be
  193.  expanded as a string in order to serve as a file name or directory
  194.  name, for example. The expansion is done according to the value given
  195.  to the `set vformat' command which initially defaults to
  196.  ``%.3g''. Using the scalar variable expansion operator in
  197.  C-calculator mode is not recommanded since a lot of precision might be
  198.  lost (actually it is a waste!). Scalar variable expansion is
  199.  essentially provided to allow alternative procedures in certain cases,
  200.  such as generating filenames from numbers. Math function `scan'
  201.  can be considered as the complement of scalar variable expansion.
  202.  
  203.  The `$' character also expands string variables. Expansion is done by
  204.  replacing the $"String-Variable-Name" by the value of the string
  205.  variable. This can be used to replace `scan' in cases where the
  206.  string variable or constant represents a number. For example
  207.  
  208.      foreach File in echo 2.2 4.4 6.7 8.32
  209.          let x = $File
  210.          .
  211.          .
  212.          .
  213.      end
  214.  
  215.  In both cases, if the variable name has to be followed by alphanumeric
  216.  characters, then the variable name can be delimited by braces as in
  217.  standard csh.
  218.  
  219.  Followed by an integer number, the `$' character serves to designate
  220.  the arguments of a macro. Refer to the description of `macro',
  221.  concerning this point.
  222.  
  223.  Syntax:
  224.      $"name"
  225.  
  226.  or
  227.  
  228.      ${"name"}
  229.  
  230.  See also:
  231.      C, cmode, macro, echo, exit
  232.  
  233. ?_dumplot
  234.  
  235.  Command `_dumplot' is generally used in a macro to dump vectors
  236.  in the plotting pipe. It is described in more detail under 
  237.  `special' item.
  238.  
  239. ?_killplot
  240.  
  241.  Command `_killplot' is rarely used. It sends a KILL signal to the
  242.  plotting program. It is described in more detail under `special'
  243.  item.
  244.  
  245. ?adjust
  246.  
  247.  The `adjust' command is used to specify the parameters to be
  248.  adjusted in the ``least square linear'' and the ``Marquardt-Levenberg
  249.  nonlinear'' fitting methods. Parameters not being adjusted will have
  250.  their standard deviation set to zero.
  251.  
  252.  Syntax:
  253.      adjust "index-list"
  254.  
  255.  Example:
  256.      adjust 1 2 4
  257.  
  258.  See also:
  259.      set parameters, set method, set function, fit, show fit
  260.  
  261. ?alias
  262.  
  263.  The `alias' command is used to alias a multiple word command to a
  264.  single word. Although macros and aliases are different objects, it is
  265.  not allowed to define a macro and an alias with the same name since
  266.  aliases are always expanded first. Recall that the bang operator
  267.  (`!'), at the beginning of a line is recognized from a macro, an alias
  268.  or a script file so that an alias like
  269.  
  270.      alias date !date
  271.  
  272.  is perfectly legal. However, this would have to be typed
  273.  
  274.      alias date ! date
  275.  
  276.  at the interactive command line, to avoid that the `!' be interpreted
  277.  by the history functions.
  278.  
  279.  When called without arguments, `alias' will list all the current
  280.  aliases. For obvious reasons, it is not allowed to `alias' 
  281.  "unalias". `alias' also supports the command abbreviation character
  282.  `!'. To enter a `!' without having it interpreted by the history
  283.  functions, just `set noexpand' for the time entering the command.
  284.  When a `!' is part of the alias name this indicates that the alias
  285.  command name can be abbreviated down to that point. Since the `&'
  286.  operator is used to refer to the native commands, it is therefore
  287.  forbidden to start an alias name by character '&'.
  288.  
  289.  Syntax:
  290.      alias "command" "command-list"
  291.  
  292.  Examples:
  293.      alias mv !mv
  294.      alias . quit
  295.      alias da!te !date
  296.  
  297.  See also:
  298.      !, &, macro, unalias, set expand
  299.  
  300. ?append
  301.  
  302.  The `append' command can be used to append various things to an
  303.  existing file. If the file does not already exists, it will be
  304.  automatically created.
  305.  
  306.  The `save' command can be used to save various things to a file.
  307.  If a file with the same name already exists, it will be overwritten
  308.  without any warning.
  309.  
  310. ?append history
  311. ?save history
  312.  
  313.  History can be saved or appended to a file. Any file saved this way
  314.  can later be executed by the `load' command. Note that `append
  315.  history' will silently fail if the file does not exist.
  316.  
  317.  Syntax:
  318.      append history "filename"
  319.      save history "filename"
  320.  
  321.  See also:
  322.      load, line editing, fmode
  323.  
  324. ?append macros
  325. ?save macros
  326.  
  327.  All the current macros and aliases can be saved or appended to a file.
  328.  Any file saved this way can be subsequently `load'ed at any time.
  329.  To avoid confusion between data files and script files we recommand
  330.  that you use the ".ft" extension for your script files.
  331.  
  332.  Syntax:
  333.      append macros "filename"
  334.      save macros "filename"
  335.  
  336.  See also:
  337.      alias, unalias, load, show, macro, unmacro
  338.  
  339. ?append parameters
  340. ?save parameters
  341.  
  342.  Parameters can be saved into a file at any time. The number output
  343.  format will be the one chosen by the `set format' command. The
  344.  column order will be a parameter followed by its standard deviation.
  345.  All columns are separated by a tab. Therefore, if one has previously
  346.  set parameters, i.e.
  347.  
  348.      set parameters MYPAR 3
  349.       .
  350.       .
  351.       .
  352.      save parameters myfile
  353.  
  354.  then there will be 6 columns as follows:
  355.  
  356. MYPAR[1]    DMYPAR[1]       . . .      MYPAR[3]     DMYPAR[3]
  357.  
  358.  in file "myfile". Most of the time, the user will desire to
  359.  save parameters along with some variables or constants. This can be
  360.  done by giving the variable or constant (either string or scalar)
  361.  names on the command line. For example,
  362.  
  363.      let t = 0.23
  364.      set parameters A 2
  365.      .
  366.      .
  367.      .
  368.      save parameters t parfile
  369.  
  370.  will create a file "parfile" containing the value of scalar
  371.  variable `t', followed by the 2 values of parameters `A',
  372.  alternated with the value of their standard deviations `DA'.
  373.  Note that the given list of variables will be printed first.
  374.  
  375.  Syntax:
  376.      append parameters "variable-list(optional)" "filename"
  377.      save parameters "variable-list(optional)" "filename"
  378.  
  379.  See also:
  380.      set format, set parameters, show parameters
  381.  
  382. ?append variables
  383. ?save variables
  384.  
  385.  Any variable or number of variables can be saved to a file at any
  386.  time. Vector elements referenced by an explicit index are considered
  387.  as variables. String variables and constants are recognized as well.
  388.  
  389.  Syntax:
  390.      append variables "variable-list" "filename" 
  391.      save variables "variable-list" "filename"
  392.  
  393.  Examples:
  394.      append variables x Y[3] a VECTOR[78] datafile1
  395.      save variables t PARAM[2] DPARAM[2] datafile2
  396.  
  397.  See also:
  398.      load, cmode, let, C, show, auto
  399.  
  400. ?append vectors
  401. ?save vectors
  402.  
  403.  Any vector or number of vectors can be saved to a file. All the values
  404.  are written in columns separated by a tab. The number format will be
  405.  the one chosen by the `set format' command.
  406.  
  407.  Syntax:
  408.      append vectors "VECTOR-list" "filename"
  409.      save vectors "VECTOR-list" "filename"
  410.  
  411.  Examples:
  412.     append vectors X Y ERROR1 TEST2 datafile1
  413.     save vectors TIME TEMP DT datafile2
  414.  
  415.  See also:
  416.      set format, set data, read, fit, fft, show, auto
  417.  
  418. ?auto
  419.  
  420.  The `auto' keyword is used to define automatic variables. The type
  421.  of variable can be a scalar variable, a VECTOR or a String, depending
  422.  on the upper-lower case letters in the variable name. The scope of
  423.  auto variables is delimited by braces as in C. All auto variables are
  424.  stored on the stack and are freed when the scope of the variable is
  425.  left. Definition of variables can only be done right after a brace has
  426.  been opened. Only scalar variables can be assigned as the are defined,
  427.  while vectors are assigned to zero, and strings are empty. Contrarily
  428.  to C, automatic scalar variables are set to zero if not assigned.
  429.  `auto' is a C-calculator mode keyword.
  430.  
  431.  Syntax:
  432.      auto "var-list"
  433.  
  434.  Examples:
  435.      # Some dummy examples
  436.      set data 100
  437.      cmode
  438.         x = y = 1                # These (x, y) are global
  439.         X = y++                  # As well as vector X
  440.         { auto x=2, X, Y         # All these variables are local...
  441.            X=3; Y=sin(x)
  442.             .
  443.             .
  444.             .
  445.         }                        # ...and stop existing here
  446.         x                        # This x still contains 1
  447.      # An example with a procedure
  448.         proc test(x) {
  449.            auto y=2
  450.            z = x + y++           # This z is global
  451.         }
  452.      fmode
  453.  
  454.  See also:
  455.      C, cmode, func, proc
  456.  
  457. ?break
  458.  
  459.  The `break' keyword is used as in C to break C-calculator mode
  460.  `for' or `while' loops. `break' is a C-calculator mode
  461.  command.
  462.  
  463.  Syntax:
  464.      break
  465.  
  466.  See also:
  467.      C, continue, cmode, for, while
  468.  
  469. ?C
  470.  
  471.  The following gives a brief description of the supported C-calculator
  472.  syntax and differences with standard C.
  473.  
  474.  The following operators are recognized, in order of precedence:
  475.  
  476.     ++, --                          (post and pre) increment-decrement
  477.     -, !                            unary minus and logical NOT
  478.     ^                               exponentiation, right associative
  479.     /, *, %                         division, multiplication, modulo
  480.     +, -                            addition, subtraction
  481.     >, >=, <, <=, ==, !=            relational operators
  482.     &&                              logical AND
  483.     ||                              logical OR
  484.     =, +=, -=, /=, *=               assignments, right associative
  485.  
  486.  All operators are left associatives except those specified.
  487.  They are all common to C except for the exponentiation operator.
  488.  
  489.  The following keywords are reserved tokens:  `auto, if, else, while,
  490.  for, break, continue', and `return', plus two extra keywords 
  491.  `proc, func'. They roughly obey the same syntax as in C so that statements
  492.  like:
  493.  
  494.      if ("conditions")
  495.          "cmode-line-statement"
  496.  
  497.  or
  498.  
  499.      if ("conditions") "cmode-line-statement"
  500.  
  501.  or
  502.  
  503.      if ("conditions") {
  504.           "cmode-statements"
  505.      }
  506.  
  507.  The same thing is true for the else constructions `else' of which
  508.  some examples follow:
  509.  
  510.      if ("conditions") 
  511.          "cmode-line-statement"
  512.      else
  513.          "cmode-line-statement"
  514.  
  515.  or
  516.  
  517.      if ("conditions") {
  518.          "cmode-statements"
  519.      } else {
  520.          "cmode-statements"
  521.      }
  522.  
  523.  Here "cmode-line-statement" means any semicolon separated list
  524.  of C-calculator mode statements typed on the same line. Since
  525.  semicolons are separators and not terminators, empty statements are
  526.  defined by empty braces `{ }'.
  527.  
  528.  The `return' keyword must have parentheses when returning a value
  529.  from a function as in `return(x * sin(y))'. A single `return'
  530.  will only be recognized from within a procedure.
  531.  
  532.  To avoid potential confusion with variables, keywords cannot be
  533.  abbreviated.
  534.  
  535.  As opposed to C, there exists no integer in the C-calculator mode. All
  536.  scalar variables and numbers are double precision. This means that
  537.  logical true is 1.0 and false is 0.0. As in C, one must be careful
  538.  with comparison operators. The C `switch' syntax is not supported
  539.  (would require integers).
  540.  
  541.  As an extension, string comparison is possible with the equality
  542.  operators `==' and `!='. This will return true or false if the string
  543.  variables (or constants) are identical or not. Assignments of string
  544.  variables actually copies all characters of the string on the RHS to
  545.  the string variable on the LHS. String additions and subtractions are
  546.  also possible.
  547.  
  548.  Function and procedure definitions are defined with prototypes, i.e.,
  549.  a list of variables representing the proper kind of variable. At
  550.  run-time, the arguments of the function are checked for type
  551.  compatibility and for their number.
  552.  
  553.  All variables are global except automatic variables defined using the
  554.  `auto' keyword. 
  555.  
  556.  See also:
  557.      cmode, let, math, scan, strings, auto
  558.  
  559. ?cd
  560.  
  561.  The `cd' command changes the working directory. Called with no
  562.  argument, `cd' will bring you to your $HOME directory. Note that
  563.  `cd' changes the current working directory of FUDGIT only.
  564.  Therefore, your plotting program will still be in the previous
  565.  directory. To get around this difficulty, you only have to define a
  566.  macro as follows, if your plotting program supports `cd':
  567.  
  568.      macro Cd 1
  569.          pmode cd "$1"
  570.          &cd $1
  571.      stop
  572.      alias cd Cd
  573.  
  574.  Syntax:
  575.      cd "filename(optional)"
  576.  
  577.  Examples:
  578.      cd
  579.      cd /nazgul/users/fulano
  580.  
  581.  See also:
  582.      &, pwd, alias
  583.  
  584. ?cmode
  585.  
  586.  The `cmode' command allows you to go in the C-calculator mode. The
  587.  only way to come back to the main fitting mode is by using the 
  588.  `fmode' command or to type ^D in interactive mode. Commands cannot
  589.  be abbreviated in `cmode'. Parallel to the `cmode' command,
  590.  the `let' command can be used to pass one single command, or
  591.  command line to mathematical parser. To be consistent with `pmode'
  592.  command, `cmode' also accepts arguments in which case it is
  593.  equivalent to the `let' command. It is not an error to call 
  594.  `cmode' from the C-calculator mode. A warning message will be given
  595.  though.
  596.  
  597.  Syntax:
  598.      cmode "command-list(optional)"
  599.  
  600.  The C-calculator mode supports most of C syntax (see item C), and most
  601.  of the C math library. Thus, the following functions are supported:
  602.  
  603.     trigo:    hyperbolic:  expo:    special:   conversion:  random:
  604.  
  605.     cos()     cosh()       ln()      besy0()    trunc()     srand()
  606.     cot()     coth()       log()     besy1()    floor()     rand()
  607.     csc()     csch()       exp()     besj0()    ceil()
  608.     sec()     sech()       sqrt()    besj1()    rint()
  609.     sin()     sinh()       cbrt()    besjn()    abs()
  610.     tan()     tanh()                 besyn()    int()
  611.     acos()   acosh()                 erf()      scan()
  612.     asin()   asinh()                 erfc()     min()
  613.     atan()   atanh()                 lgamma()   max()
  614.     atan2()                          interp()   sum()
  615.                                                 vread()
  616.  
  617.  Any upper case variable (possibly including `_') possibly mixed with
  618.  digits will be recognized as a vector, e.g., `TEMP_2, TEST, D',
  619.  etc. Any lower case name will be taken as a scalar variable, e.g.,
  620.  `x, t4', etc. There are two predefined constants, `pi' =pi
  621.  and `e'=e, which should not be unlocked and modified. As well,
  622.  the built-in constant `data' contains the current size of the
  623.  vectors and can be modified through the `set data' command, by the
  624.  `read'/`exec' commands, or by `unlock'ing the constant and
  625.  modifying it directly. The built-in constant `chi2' contains the
  626.  value of chi^2 as obtained from the latest fit. And finally, the
  627.  built-in scalar constant `param' contains the number of parameters
  628.  as defined by `set parameters'.
  629.  
  630.  A mix of upper case and lower case letters will serve to indicate a
  631.  string variable. Strings values are indicated by double quotes as in
  632.  C. Unlike C, FUDGIT considers strings as self-contained objects that
  633.  can be added, subtracted, and checked for (in)equality. Thus, string
  634.  objects (i.e. string variables, string constants and string values)
  635.  can: serve as argument to `scan' function; be part of string
  636.  assignment statements or of a truth statement involving (in)equality
  637.  operator; be added (concatenated using the `+' operator) one with
  638.  another; be subtracted (remove string termination using the `-'
  639.  operator) one with another; and finally be argument of string
  640.  functions.
  641.  
  642.  A predefined string constant called `Tmp' contains the string
  643.  "/tmp/fudgitPID" where PID is the process id number of the current
  644.  process. This file, and any file belonging to you, whose name starts
  645.  with the same string, will be erased automatically by the `exit'
  646.  or `quit' commands. This string is typically used by the 
  647.  `gnuplot' macro in order to pass data to the GNUPLOT plotting program
  648.  which cannot read data from standard input. Another predefined string
  649.  constant is `ReadFile' which contains the last data filename that
  650.  has been loaded. Finally, the string constant `Cwd' is made
  651.  available in order to get the current working directory.
  652.  
  653.  The following table contains all the built-in constants.
  654.  
  655.     chi2               Value of chi^2 from the last fit;
  656.     data               Length of all vectors (< samples) as set by set data;
  657.     e                  Neperian number;
  658.     param              Number of parameters as set by set parameters;
  659.     pi                 Guess this one;
  660.  
  661.     Cwd                Current working directory;
  662.     ReadFile           The last file (program) read by read (exec);
  663.     Tmp                A temporary filename "/tmp/fudgitPID";
  664.  
  665.  Constants (either strings and scalars) can also be created by 
  666.  `lock'ing a variable. In the same manner, a constant can be modified
  667.  directly if it has been `unlock'ed.
  668.  
  669.  The algebraic operations applicable to scalar variables can be applied
  670.  to vectors. Vector algebra can be mixed with scalar variable algebra
  671.  in which case the user has to take the implied loop into account. For
  672.  example, although the following operation is not standard C
  673.  programming:
  674.  
  675.  NOTE: In order to show that some commands can be typed from both
  676.  C-calculator mode and the fitting fmode, the following examples shows
  677.  the typing mode from the first line. However, one can always type the
  678.  same C-calculator mode command from the fitting mode by using the 
  679.  `let' command (or `cmode' command).
  680.  
  681.      cmode
  682.          x = 0
  683.          X = x++
  684.  
  685.  will define a vector X of size `data' (see `set data')
  686.  ranging from X[1] to X[data] and taking values from 0 to
  687.  data-1. Multiple commands can be given with the separator `;', for
  688.  example, another version of the previous command could be written
  689.  
  690.      cmode
  691.          x=0;X=++x
  692.  
  693.  in which case a vector X taking values from 1 to data will be
  694.  created. (Note that the latter uses a pre-increment whereas the
  695.  former uses a post-increment operator on `x': results are thus
  696.  different). Vector elements can be referenced by elements using
  697.  standard C grammar. Therefore, the same vector could be created by
  698.  using a `while' construction as in:
  699.  
  700.      fmode
  701.      set data 1000
  702.      let X=0;i=0
  703.      cmode
  704.          while (i++ <= data)
  705.             X[i] = i
  706.      fmode
  707.  
  708.  or, using a `for' loop, 
  709.  
  710.      cmode
  711.         for (x=0;x<=data;x++) {
  712.             X[x] = x
  713.         }
  714.      fmode
  715.  
  716.  Noninteger variables will be truncated to the nearest lower integer to
  717.  form a vector index.
  718.  
  719.      cmode
  720.          y= 2.01
  721.          x=2.23; X[2]=Z[y]+5^x 
  722.  
  723.  Assigning a vector to a constant will assign all the elements to that
  724.  constant.
  725.  
  726.      fmode
  727.      let X = pi
  728.      let Z2 = 0
  729.  
  730.  The C-calculator checks for undefined variables on the RHS of any
  731.  assignment. From C-calculator mode, variables values can be seen by
  732.  typing the variable name by itself or by using the `print'
  733.  command, if the output is selected to be "stdout". From the
  734.  fitting mode, contents of constants and variables (either strings or
  735.  scalars) is displayed using `show variables' command, or by using
  736.  the `$' expansion operator. However, vectors can be only be seen from
  737.  the fitting mode by using the `show vector' command.
  738.  
  739.  Each unknown vector name given on the command line allocates a vector
  740.  of `sample' size.
  741.  
  742.  To be a calculator as such, the C-calculator prints the value of the
  743.  expression given on the command line. Thus, the statement
  744.  
  745.      cmode
  746.          x + 2
  747.  
  748.  will print the value of x + 2.0. The contents of many variables can
  749.  be displayed at the same time by giving a coma separated list such as
  750.  in
  751.  
  752.      cmode
  753.          x,"temperature", t
  754.  
  755.  where the string "temperature" will be printed between the values
  756.  of variables x and t. Note that the C-calculator mode recognizes
  757.  strings by double quotes. Special characters such as '\n' are
  758.  also legal in a string.
  759.  
  760.  We conclude by giving some examples involving string variables:
  761.  
  762.      fmode
  763.      let String = "new.file"
  764.      let x = (String == "new.file")
  765.      let y = ("file1" == "file2")
  766.      let Bing = "aaa"
  767.      let Here = Cwd        # Store the value of the current working directory
  768.      let Input = Read()                       # Read from stdin
  769.      let Test = FileName(ReadFile) - ".data"
  770.      let Dir = DirName(InputFile)
  771.      let y = scan(Read(), "%lf")
  772.      let File = "STRING_23.4"
  773.      let number = scan("%*[_A-Z]%lf", File)
  774.      let Message = "A tab t and a newlinen"
  775.  
  776.  where the truth statement could be legally used as a condition for an
  777.  `if', a `while', or a `for'.
  778.  
  779.  See also:
  780.      let, C, data, func, proc, print, fmode, math, while, for, return,
  781.      auto, if, break, samples, quotes, strings
  782.  
  783. ?comments
  784.  
  785.  By default, anything following a ``#'' will be treated as a
  786.  comment and ignored. This holds for data files as well as for command
  787.  script files loaded with the `load' command. This default can be
  788.  changed with the `set comment' command. Sometimes a comment
  789.  character needs to be taken literally in a script file. The comment
  790.  character will be accepted as data if it follows the `\' escape
  791.  operator, i.e. `\#', or, in the fitting mode only, whenever the
  792.  comment character is somewhere inside quotes or parentheses. The
  793.  comment character is always accepted literally when typed on the
  794.  interactive command line.
  795.  
  796.  See also:
  797.      set comment, read, load, show comment, exec
  798.  
  799. ?continue
  800.  
  801.  The `continue' keyword has the same usage it has in C for sending
  802.  the control to the next iteration of a `for' or `while' loop.
  803.  `continue' is a C-calculator mode command.
  804.  
  805.  Syntax:
  806.      continue
  807.  
  808.  See also:
  809.      for, while, cmode, C
  810.  
  811. ?datafiles
  812.  
  813.  Files containing data are loaded by specifying the name of the data
  814.  file to the `read' command. Data files should contain one data
  815.  point per line. A data point can be a 256 dimensional object. By
  816.  default, anything following character ``#'' will be treated as
  817.  comment and ignored. In all cases, the numbers on each line of a data
  818.  file must be separated by any number of blank spaces or tabs. These
  819.  blanks divide each line into columns. Thus, FUDGIT can handle up to
  820.  256 columns per line. Warning will be given if a line has a different
  821.  number of columns. Strings such as "NaN" or "Infinity" are
  822.  recognized and refused. The default compilation gives a maximum line
  823.  size of 1024 characters.
  824.  
  825.  See also:
  826.      read, exec, set comment
  827.  
  828. ?echo
  829.  
  830.  The `echo' command allows the user to print a string to the
  831.  standard output. If no argument is given `echo' will only print a
  832.  newline. This command can be used to display a message or, when
  833.  coupled with the variable expansion operator `$', to see the value of
  834.  a printable (either string or scalar) variable defined in the
  835.  C-calculator.
  836.  
  837.  Syntax:
  838.      echo "string-list"
  839.  
  840.  Examples:
  841.       echo Starting the fit
  842.       echo $Mydir
  843.  
  844.  See also:
  845.      cmode, $
  846.  
  847. ?else
  848.  
  849.  The `else' keyword is used in `if' constructions, both in
  850.  C-calculator anf fitting modes. Refer to the `if' entries for a
  851.  complete description.
  852.  
  853. ?end
  854.  
  855.  The `end' command is used to complete a `foreach' loop or a
  856.  `while' loop. Keyword `end' is also used to tell `read'
  857.  that we are finished writing data to stdin. This command should always
  858.  be found on a line by itself (comments are allowed though).
  859.  
  860.  See also:     foreach, while, read, stop
  861.  
  862. ?endif
  863.  
  864.  The `endif' command is used to complete an `if' construction
  865.  in fitting mode. Keyword `endif' must always be used on a line by
  866.  itself (comments are allowed though). Refer to the `if' entries
  867.  for a the complete description.
  868.  
  869. ?environment
  870.  
  871.  FUDGIT is sensitive to the following environment variables:
  872.  
  873.    =>  PAGER for the program called to format long listings.
  874.  
  875.    =>  HOME for the directory to which `cd' defaults.
  876.  
  877.    =>  SHELL for the shell called by `system' when this
  878.           latter is called without arguments.
  879.  
  880.  If not defined, the default pager is "/usr/?/more" (path depends
  881.  on system) and the default shell "/bin/csh".
  882.  
  883.  See also:
  884.      cd, system, show vectors, help
  885.  
  886. ?exec
  887.  
  888.  The command `exec' executes a program and reads data from it. It
  889.  supports the same syntax `read' does except that the program name
  890.  replaces the file name. A program is a program name or anything that
  891.  can be typed in a shell. If the command line has more than one string,
  892.  it must be glued with quotes. On a successful call, `exec' will
  893.  set the string constant `ReadFile' to the name of the program
  894.  which generated the data.
  895.  
  896.  Syntax:
  897.      exec "commands" "assignment[range](optional)" ...
  898.  
  899.  Examples:
  900.      exec simulate X:1 Y:2[0:200]
  901.      exec "cat data | myfilter -g" X1:1[0:*] X2:2 X3:4
  902.  
  903.  See also:
  904.      read, comments
  905.  
  906. ?exit
  907.  
  908.  The commands `exit' and `quit' will exit FUDGIT.
  909.  See details under item `quit'.
  910.  
  911.  Syntax:
  912.      exit
  913.  
  914.  See also:
  915.      quit, cmode
  916.  
  917. ?fft
  918.  
  919.  The `fft' command will take the Fourier transform of the specified
  920.  vectors and put the real part in a vector specified by the third
  921.  argument. The imaginary part will be put in a vector specified by the
  922.  fourth argument. Input vectors can be used for output. The resulting
  923.  vectors will contain frequencies ranging from 0 to N/2 followed by
  924.  -(N/2 - 1) to -1 in units of 1/(N*Delta) where Delta is the
  925.  sampling rate. If a real vector is transformed h(t) -> H(f), we
  926.  should have H(-f) = H^*(f). Therefore, with H = R + iI and
  927.  H^* = R - iI be the transformed vectors, we should have
  928.  R(-f) = R(f) and I(-f) = -I(f), where f is discrete and ranges
  929.  as mentioned above. In terms of vector indices, these relations
  930.  become R[i] = R[N-i+2] and I[i] = -I[N-i+2] for 1 < i < N/2 in
  931.  addition to the fact that I[1] = I[(N/2)+1] = 0. Therefore, because
  932.  the negative frequency part is the mirror image of the positive one,
  933.  it is common to plot only the positive frequencies of the Fourier
  934.  transform of a real vector. This can be done by reducing `data' to
  935.  half its value.
  936.  
  937.  Because of the use of a FFT algorithm, the number of data points must
  938.  be an integer power of 2. If not, the user should pad the vector with
  939.  zeros up to the next largest power of two. Each transform is
  940.  normalized by the factor sqrt(N) so that `fft RE IM T_RE T_IM'
  941.  followed by `invfft T_RE T_IMA RE2 IMA2' will not introduce a
  942.  factor N in vectors `RE2' and `IMA2' (i.e., `RE' = `RE2'
  943.  and `IM' = `IM2'). At his choice, the user can use the
  944.  C-calculator functionality in order to implement windowing.
  945.  
  946.  The power spectrum can be obtained from:
  947.  
  948.       fft RE IMA T_RE T_IMA
  949.       let POW = T_RE^2 + T_IMA^2
  950.  
  951.  where POW[i] will contain the power value associated with frequency f,
  952.  which goes from 0 to N/2 followed by -(N/2 - 1) to -1 (in units
  953.  of 1/(N*Delta)) as i goes from 1 to N.
  954.  
  955.  Syntax:
  956.      fft "real-VECTOR" "ima-VECTOR" "real-VECTOR" "ima-VECTOR"
  957.  
  958.  Examples:
  959.       # real vector X
  960.       let IM=0
  961.       # re-use IM vector for output
  962.       fft X IM Z IM
  963.       # complex vectors X+iY where i = sqrt(-1) transformed in V+iW  
  964.       fft X Y V W
  965.  
  966.  See also:
  967.      invfft, smooth, cmode, let, read, math, data
  968.  
  969. ?fit
  970.  
  971.  The `fit' command is used to fit a function, chosen by `set
  972.  function', to a pair of vectors containing the independent and
  973.  dependent variables. Depending on the type of fit, selected by the
  974.  `set method' command, a third vector containing the standard
  975.  deviation might be required. `fit' allocates a vector having the
  976.  name of the dependent variable appended with the string `FIT'.
  977.  This vector contains the computed values of the function for the given
  978.  independent vector. Depending on the method, the built-in constant
  979.  `chi2' will contain the value of the mean square deviation
  980.  weighted by vector "sigma-VECTOR" or the mean absolute deviation.
  981.  
  982.  Syntax:
  983.      fit "independent-VECTOR" "dependent-VECTOR" "sigma-VECTOR"
  984.  
  985.  Example:
  986.      fit X Y DY
  987.  
  988.  will create a vector `YFIT' containing the value of the fitted
  989.  function for each of the values of the independent vector `X'.
  990.  Note that the standard deviation is required for most fitting routines
  991.  since it is used to weigh the value of local square deviation from the
  992.  fit (in fact, this is the definition of chi^2). If 
  993.  "sigma-VECTOR" is unavailable just use
  994.  
  995.      let DY=1
  996.  
  997.  using the previous example. This simply gives the same weight to all
  998.  data points.
  999.  
  1000.  See also:
  1001.      set method, set function, show fit, show parameters, append
  1002.  
  1003. ?fmode
  1004.  
  1005.  The `fmode' command allows you to return to the fitting mode, when
  1006.  the program is in one of the C-calculator or plotting modes. The
  1007.  fitting mode, is the main mode of the program. The two other modes are
  1008.  the C-calculator mode, accessed by the `cmode' command, and the
  1009.  plotting mode, accessed by the `pmode' command. When used
  1010.  interactively, ^D returns to the fitting mode from either of the
  1011.  C-calculator mode or from the plotting mode. It is not an error to
  1012.  call `fmode' from the fitting mode. A warning message will be
  1013.  given though.
  1014.  
  1015.  Syntax:
  1016.      fmode
  1017.  
  1018.  See also:
  1019.      cmode, pmode, let
  1020.  
  1021. ?for
  1022.  
  1023.  The `for' command is a C-calculator mode command. It behaves
  1024.  roughly like a standard C `for' construction. In interactive
  1025.  mode, any new input line will be prompted with a ``n{... n\t''
  1026.  where `n' stands for the nesting level and `\t' for a tab.
  1027.  Keyword `for' is a C-calculator mode command.
  1028.  
  1029.  Syntax:
  1030.      for ("init-expressions"; "cond-expressions"; "loop-expressions") 
  1031.            "cmode-line-statement"
  1032.  
  1033.  or 
  1034.  
  1035.      for ("init-expressions"; "cond-expressions"; "loop-expressions") {
  1036.            "cmode-statements"
  1037.      }
  1038.  
  1039.  Examples:
  1040.      cmode
  1041.          for (i=1,j=2;i+j <= data; i+=2,j+=3) A[i] = X[j]
  1042.      fmode
  1043.      # Another example:
  1044.      # A macro to remove point x in a vector. Syntax: delete "vector" "index"
  1045.      macro delete 2
  1046.          cmode
  1047.              for(i=$2;i<data;i++) {
  1048.                  $1[i] = $1[i+1]
  1049.              }
  1050.          fmode
  1051.          unlock data
  1052.          let data--
  1053.          lock data
  1054.      stop
  1055.  
  1056.  See also:
  1057.      C, break, continue, cmode, if, set data, func, proc, if, lock, math
  1058.  
  1059. ?foreach
  1060.  
  1061.  The `foreach' command loops through the strings obtained from a
  1062.  given UNiX command. Wild card characters are allowed since
  1063.  everything following the `in' keyword is passed to a Bourne shell
  1064.  for execution. Strings can be obtained from any program including the
  1065.  easiest cases "echo, ls" and "cat". The variable name must be
  1066.  of string type, i.e., consisting of both upper case and lower case
  1067.  letters (and possibly _'s and digits).
  1068.  
  1069.  Syntax:
  1070.      foreach "StringVarName" in "UNiX-command"
  1071.           "body of the loop"
  1072.      end
  1073.  
  1074.  Example:
  1075.      #convert columns 2 and 3 of the following files in log-log format
  1076.      foreach Fname in ls data*.7[0-9] datatest.42 data*.8[4-7]
  1077.          echo $Fname ...
  1078.          read $Fname X:2[0.001:*] Y:3[0.001:*]
  1079.          let X = log(X)
  1080.          let Y = log(Y)
  1081.          save vectors X Y $Fname.log
  1082.      end
  1083.  
  1084.  See also:
  1085.      for, math function scan, while, macro
  1086.  
  1087. ?free
  1088.  
  1089.  The command `free' is made available for memory management. It is
  1090.  used to free vectors, variables, functions, procedures, and numbers
  1091.  that were allocated in the C-calculator mode.
  1092.  
  1093.  When called with the special argument ``@all'', `free' will erase
  1094.  all the user vectors, numbers and variables, as well as all active
  1095.  functions and procedures (not macros and aliases). Otherwise, `free'
  1096.  will free the specified vector(s) or variable(s). Constants (either
  1097.  scalar or string) cannot be removed without first unlocking them.
  1098.  
  1099.  Syntax:
  1100.      free "VECTOR- or variable-list" 
  1101.      free @all
  1102.  
  1103.  Examples:
  1104.       free @all
  1105.       free X y TEMP
  1106.  
  1107.  See also:
  1108.      unlock, C, cmode, show table, show memory, samples, let
  1109.  
  1110. ?func
  1111.  
  1112.  The `func' command defines a function. A function is distinct from
  1113.  a procedure from the fact that a function must return a value whereas
  1114.  a procedure must not. Arguments are given in the definition with any
  1115.  name prototype representative of the data type. As in C, the argument
  1116.  list must be comma separated when calling the function (after having
  1117.  defined it). An example follows. `func' is a C-calculator mode
  1118.  command.
  1119.  
  1120.  The prototype list defines the type of variable to be used. Although
  1121.  all global variables are accessible from within the function,
  1122.  variables are always searched for from the prototype list first, then
  1123.  from the local list (`auto' variables), and finally from the
  1124.  global list. All scalar variables are passed by value: thus any scalar
  1125.  expression is legal as scalar argument. String arguments and vector
  1126.  arguments are passed by pointer: thus string and vector arguments must
  1127.  refer to a variable explicitly. The `show table' can be used to
  1128.  list all the installed objects at a given time.
  1129.  
  1130.  Syntax:
  1131.      func "functionname"("proto-list(optional)") "cmode-line-statement"; return("value")
  1132.  
  1133.  or
  1134.  
  1135.      func "functionname"("proto-list(optional)") {
  1136.           "cmode-statements"
  1137.           return("value")
  1138.      }
  1139.  
  1140.  Examples:
  1141.     # The following example will print the factorial of all integers up to 120.
  1142.     cmode
  1143.         func fac(x) {  # This `x' is a prototype: it does not exist.
  1144.             if (x <= 0)  {
  1145.                return(1)
  1146.             } else {
  1147.                return(x * fac(--x))
  1148.             }
  1149.        }
  1150.        x=1  # This `x' is a global scalar variable
  1151.        while (x<120) {
  1152.            fac(x++)
  1153.        }
  1154.     fmode
  1155.     # The following calculates the average of a vector
  1156.     cmode
  1157.         func avg(X) {
  1158.             auto i,x
  1159.  
  1160.             for (x=0,i=1;i<=data;i++) {
  1161.                 x += X[i]
  1162.             }
  1163.             return(x/data)
  1164.         }
  1165.     fmode
  1166.  
  1167.  See also:
  1168.      C, return, for, while, cmode, math, free, proc, show table, install
  1169.  
  1170. ?help
  1171.  
  1172.  The `help' command displays on-line help. To specify information on a
  1173.  particular topic use the syntax:
  1174.  
  1175.      help "topic"
  1176.  
  1177.  If "topic" is not specified, a short message is displayed about
  1178.  FUDGIT. Topic names can be abbreviated down to the shortest
  1179.  unambiguous string. In case of doubt, `help' will print out all
  1180.  possible completions. Thus, `help f' will print all help topics
  1181.  starting with the letter `f'. After help for the requested topic has
  1182.  been given, help for a subtopic may be requested by typing the
  1183.  subtopic name, extending the help request. After that subtopic help
  1184.  has been displayed, the request may be extended again, or pressing
  1185.  return will return one level back to the previous topic. Eventually,
  1186.  the fitting mode prompt will return.
  1187.  
  1188.  See also:
  1189.      help?
  1190.  
  1191. ?history
  1192.  
  1193.  The `history' command lists all the previous command lines, along
  1194.  with a number. History lines can be called using the !"string"
  1195.  construction or the !"number". History is only available in
  1196.  interactive mode. See Appendix A for more details.
  1197.  
  1198.  Syntax:     history
  1199.  
  1200.  See also:
  1201.      append history, line editing
  1202.  
  1203. ?if
  1204.  
  1205.  There are two kinds of `if' constructions available in FUDGIT,
  1206.  one in the fitting mode and the other in the C-calculator mode.
  1207.  
  1208. ?if cmode_style
  1209.  
  1210.  In C-calculator mode, `if' and `else' are reserved keywords.
  1211.  C-calculator mode `if' construction is similar to the one in
  1212.  standard C. Note that "cmode-statements" refers to any sequence of
  1213.  C-calculator mode commands and that "cmode-line-statement" refers
  1214.  to a semicolon separated list of C-calculator mode commands typed on
  1215.  the same line.
  1216.  
  1217.  Syntax:
  1218.      if ("conditions") "cmode-line-statement"
  1219.  
  1220.  or
  1221.  
  1222.      if ("conditions")
  1223.          "cmode-line-statement"
  1224.  
  1225.  or
  1226.  
  1227.      if ("conditions") {
  1228.           "cmode-statements"
  1229.      }
  1230.  
  1231.  or, using the `else' constructions,
  1232.  
  1233.      if ("conditions")
  1234.           "cmode-line-statement"
  1235.      else
  1236.           "cmode-line-statement"
  1237.  
  1238.  or, for statements on more than one line,
  1239.  
  1240.      if ("conditions") {
  1241.           "cmode-statements"
  1242.      } else if ("conditions") {
  1243.           "cmode-statements"
  1244.      } else {
  1245.           "cmode-statements"
  1246.      }
  1247.  
  1248.  See also:
  1249.      C, cmode
  1250.  
  1251. ?if fmode-style
  1252.  
  1253.  Fitting mode `if' has a syntax very similar to the one in C-shell.
  1254.  It requires the keywords `then' and `endif' and supports 
  1255.  `else' constructions. The difference resides in the fact that the
  1256.  conditional statement has to follow C-calculator mode grammar and
  1257.  syntax and thus has a richer set of operators. The `$' expansion
  1258.  operator is therefore not needed in the conditional statement, as it
  1259.  is in C-shell conditional statements. All active variables, constants,
  1260.  and their string counterparts, are directly available to the
  1261.  conditional statement. Note that the "fmode-statements" can also
  1262.  contain C-calculator mode commands (even possibly including
  1263.  C-calculator mode `if''s!).
  1264.  
  1265.  Syntax:
  1266.      if ("conditions") then
  1267.           "fmode-statements"
  1268.      endif
  1269.  
  1270.  or, using the `else' constructions,
  1271.  
  1272.      if ("conditions") then
  1273.           "fmode-statements"
  1274.      else if ("conditions") then
  1275.           "fmode-statements"
  1276.      else
  1277.           "fmode-statements"
  1278.      endif
  1279.  
  1280.  See also:
  1281.      while, foreach, macro
  1282.  
  1283. ?in
  1284.  
  1285.  The `in' keyword is required in `foreach' constructions in
  1286.  fitting mode. Refer to the latter for details.
  1287.  
  1288. ?install
  1289.  
  1290.  The `install' command dynamically loads defined routines from an
  1291.  object file. The user decides on the internal name of the routine but
  1292.  the internal name must consist of lower case letters only. The object
  1293.  file is an object compiled by the C or FORTRAN compiler. On IRIX, the
  1294.  object must be compiled with the option `-G 0' given to either the
  1295.  C or FORTRAN compiler. The "rtn-name" is the name of one of the
  1296.  procedure(s) or function(s) the user wants to install from the
  1297.  object file. The routine will be installed as "name" and as a
  1298.  procedure (not returning value) or as a function (returning value)
  1299.  depending on the name separator being a `:' (colon) or a `='
  1300.  (equal sign) respectively. (See example below).
  1301.  
  1302.  NOTE: This option is only available on IRIX and SUNOS for the moment.
  1303.  
  1304.  The external routine must expect pointers to double for all its
  1305.  arguments. Thus, all arguments are passed by pointers except that
  1306.  pointers to variables do not point to the variables as such but to a
  1307.  temporary copy of them. This allows us to have expressions like
  1308.  
  1309.  `f = mycall(X, sin(x) + 1, data)'
  1310.  
  1311.  for which the value `sin(x) + 1' must necessarily be a temporary copy.
  1312.  In this example, the prototype is a function `mycall(VEC, expr, expr)'.
  1313.  We shall consider an example in more detail below. All arguments are
  1314.  strongly typed as vector, parameter, expression or string. Prototyping
  1315.  is done using the uppercase-lowercase convention. Parameters are prototyped
  1316.  using the word `PARAM' or less (e.g. `PAR').
  1317.  
  1318.  On IRIX, the linker will create a binary file built from the module
  1319.  name and with the extension "file".`ld'. This binary is the
  1320.  one that will be loaded in memory. Time stamps are included so that
  1321.  `ld(1)' will not be called if not necessary. These files are not
  1322.  erased at exit, since they are reusable and prevent the linker to be
  1323.  called if nothing changed between two sessions of FUDGIT.
  1324.  
  1325.  Successive calls of `install' with the same module should not be
  1326.  done unless the same functions and procedures are reinstalled. If this
  1327.  is the case, the user should then reinstall the same modules (that
  1328.  could have been modified and recompiled in the mean time) using the
  1329.  `reinstall' command. If a module is reinstalled with different
  1330.  routines or function or procedure names, the previously defined
  1331.  functions or procedures might not be properly installed anymore and
  1332.  calling them might result in an undefined behavior.
  1333.  
  1334.  The file "fudgit.h" describes the functions user-defined programs
  1335.  can linked with. Among other things, these functions allow the user to
  1336.  have elegant error handling and exit.
  1337.  
  1338.  The `show table' command can be used to list all the installed
  1339.  objects at a given time.
  1340.  
  1341.  A file having the same base name of the module but with the extension
  1342.  "libs" can be put in the same directory in order to include extra
  1343.  libraries while loading the module. On IRIX, these extra libraries
  1344.  must all contain objects compiled with the flag "-G 0" (see 
  1345.  `cc(1)').  (For example, some IRIX systems have a -lm_G0 math
  1346.  library.) User-defined libraries can be specified along with system
  1347.  libraries. A typical example could be a line like:
  1348.  
  1349.      /home/myname/myproject/libmyG0.a /usr/lib/libmG0.a
  1350.  
  1351.  for linking with user's library "/home/myname/myproject/libmyG0.a".
  1352.  Equivalently, for non-IRIX systems, loading a FORTRAN object might
  1353.  require something like this:
  1354.  
  1355.      /usr/lib/libF77.a /usr/lib/libm.a
  1356.  
  1357.  Library names can be on multiple lines. However, the file cannot have
  1358.  more than 1024 bytes. A ``#'' found anywhere in this file will make
  1359.  the rest of the file to be ignored.
  1360.  
  1361.  Note that when loading FORTRAN code, the user must append an underscore
  1362.  to the routine name so that `install' or `reinstall' can find it.
  1363.  
  1364.  The IRIX version does not fully support incremental linking, i.e., to
  1365.  use, in an object to be installed, symbols that were defined in
  1366.  previously `install'ed objects. However, all the symbols contained
  1367.  in the original FUDGIT executable remain at all time available to
  1368.  all linked routines. Therefore, IRIX users should make sure that
  1369.  external objects are self-contained and only reference to external
  1370.  routines that are intrinsic to FUDGIT or come directly (and once)
  1371.  from linked libraries at installation time.
  1372.  
  1373.  Syntax:
  1374.      install "object-file" "rtn-name"[:|=]"name"(arg-list)...
  1375.  
  1376.  Example:
  1377.     hostname: cat mymodule.c
  1378.         #include <math.h>
  1379.         #include "fudgit.h"
  1380.         
  1381.         /* An example of a user-defined routine inversing the order of an even
  1382.          * vector. Typical call would be:
  1383.          *  myproc(A_VEC, data)
  1384.          * from C-calculator mode. NOTE that both VEC and expr are pointers.
  1385.          * To make things explicit, fudgit.h contains a few typedef's.
  1386.          */
  1387.         
  1388.         void myproc(X, dn)
  1389.         VEC X;
  1390.         expr dn;
  1391.         {
  1392.             int i, half_n;
  1393.             int n = (int)*dn;  /* note that dn is a pointer to a double */
  1394.             double tmp;
  1395.     
  1396.             if (n%2 == 1)   /* report error if odd number (Why not?)*/
  1397.                 Ft_matherror("%s: Called with an odd number %d.", "myproc", n);
  1398.  
  1399.             /* You have full use of math and stdio libraries too!!! */
  1400.             fprintf(stderr,
  1401.             "BTW, Did you know that %lf is the sqrt(pi)?n", sqrt(M_PI));
  1402.  
  1403.             half_n = n >>1;  /* half of n */
  1404.             for (i=0;i<half_n;i++) { /* Standard C: indices from 0 to data-1 */
  1405.                 tmp = X[i];
  1406.                 X[i] = X[n-i];
  1407.                 X[n-i] = tmp;
  1408.             }
  1409.         }
  1410.         
  1411.         /* 
  1412.          * Another example involving a function. The following calculates the
  1413.          * non-normalized correlation between vectors A and B as defined by 
  1414.          * corr(A, B) = <A*B> - <A> * <B>
  1415.          *
  1416.          */
  1417.         
  1418.         double myfunc(A, B, dn)
  1419.         VEC A, B;
  1420.         expr dn;
  1421.         {
  1422.             int i, n = (int)*dn;  /* Again, dn is a pointer to a double */
  1423.             double sumA, sumB, sumAB;
  1424.         
  1425.             sumA = sumB = sumAB = 0.0;
  1426.             /* sum up the values of interest */    
  1427.             for (i=0;i<n; i++) {  /* indices go from 0 to data-1 */
  1428.                 sumA += A[i];
  1429.                 sumB += B[i];
  1430.                 sumAB += A[i] * B[i];
  1431.             }
  1432.             /* leave it simple */
  1433.             sumA /= *dn;
  1434.             sumB /= *dn;
  1435.             sumAB /= *dn;
  1436.         
  1437.             return (sumAB - sumA*sumB);
  1438.         }
  1439.     hostname: cc -G 0 -O -c mymodule.c
  1440.     hostname: cat loadex.ft
  1441.         # This is an example for loading
  1442.         # Install function myfunc as corr() and procedure myproc as inverse()
  1443.         # Prototypes are made from any name representing the proper type:
  1444.         install mymodule.o myproc:inverse(V, n) myfunc=corr(V, V, n)
  1445.         set data 24
  1446.         let x=1;X=x++
  1447.         let Y=sin(X)
  1448.         cmode
  1449.             # Inverse order of vector X
  1450.             inverse(X, data)
  1451.             # Calculate correlation between X and Y
  1452.             y=corr(X, Y, data)
  1453.             # Print its value
  1454.             "correlation:", y
  1455.         fmode
  1456.     hostname: fudgit loadex.ft
  1457.     install: myproc installed as procedure inverse.
  1458.     install: myfunc installed as function corr.
  1459.     BTW, Did you know that 1.772454 is the sqrt(pi)?
  1460.     correlation: 9.20717026e-01 
  1461.  
  1462.  When linking FORTRAN functions or subroutines, the user must append an
  1463.  underscore after every function or subroutine name. All argument
  1464.  variables and vectors have to be defined `double precision' as
  1465.  well as returning functions. Typical examples are included in the
  1466.  distribution in the "tools" directory.
  1467.  
  1468.  See also:
  1469.      C, cmode, show table, func, proc
  1470.  
  1471. ?invfft
  1472.  
  1473.  Command `invfft' performs the inverse Fourier transform of the
  1474.  given vectors. It assumes that the frequencies are ordered from 0 to
  1475.  N/2 followed by negative frequencies ranging from -(N-1)/2 to -1
  1476.  in units of 1/(N*Delta) where Delta is the sampling interval.
  1477.  The results are normalized by a factor 1/sqrt(N) so that a
  1478.  transform followed by an inverse transform should give the original
  1479.  vector. The resulting vectors are stored in the third and fourth
  1480.  arguments. Thus, `invfft X Y V W' inverse transforms X+iY into
  1481.  V+iW. Input vectors can be used as output vectors. See `fft' for
  1482.  more details.
  1483.  
  1484.  Syntax:
  1485.      invfft "real-VECTOR" "ima-VECTOR" "real-VECTOR" "ima-VECTOR"
  1486.  
  1487.  See also:
  1488.      fft, smooth, cmode, let, read, math, data
  1489.  
  1490. ?let
  1491.  
  1492.  The `let' command opens the door to the C-calculator mode from the
  1493.  fitting mode, but leaves the program in fitting mode. All the 
  1494.  `let' commands can always be typed directly from the C-calculator mode
  1495.  without having to prepend with the `let' keyword. The converse is
  1496.  also true; all the commands given in C-calculator mode could be typed
  1497.  from the fitting mode by prepending them with the `let' command.
  1498.  Although `let' is typed from the fitting mode, the remainder of
  1499.  the line is parsed according to C-calculator mode rules, and thus
  1500.  quotes are no longer swallowed. Variable expansion operator `$' is
  1501.  still recognized, but its use is not recommanded for C-calculator
  1502.  statements. See `$' for more details on this point.
  1503.  
  1504.  Syntax:
  1505.      let "C-calculator-mode-commands"
  1506.  
  1507.  Examples:
  1508.       # generate the zero order first kind bessel
  1509.       # function between (0, 2*pi]
  1510.       fmode
  1511.       set data 2000
  1512.       let x=1; X=x++
  1513.       let tmp = 2*pi/data     # compute sequence only once
  1514.       let X *= tmp
  1515.       let Y = besj0(X)
  1516.  
  1517.  See also:
  1518.      cmode, C, math
  1519.  
  1520. ?editing
  1521. ?line
  1522.  
  1523.  The command shell supports line editing and history. The editing
  1524.  commands are based on the basic EMACS commands. A short summary
  1525.  follows but a more complete description can be found in Appendix B.
  1526.  
  1527.  Line editing:
  1528.  
  1529.    =>  ^B moves back a single character.
  1530.  
  1531.    =>  ^F moves forward a single character.
  1532.  
  1533.    =>  ^A moves to the beginning of the line.
  1534.  
  1535.    =>  ^E moves to the end of the line.
  1536.  
  1537.    =>  ^H and DEL delete the previous character.
  1538.  
  1539.    =>  ^D deletes the current character.
  1540.  
  1541.    =>  ^K deletes from current position to the end of line.
  1542.  
  1543.    =>  ^L,^R redraws line in case it gets trashed.
  1544.  
  1545.    =>  ^U deletes the entire line.
  1546.  
  1547.    =>  ^W deletes the last word.
  1548.  
  1549.  History:
  1550.  
  1551.    =>  ^P moves back through history.
  1552.  
  1553.    =>  ^N moves forward through history.
  1554.  
  1555.    =>  !!   previous command.
  1556.  
  1557.    =>  !$  previous command last argument.
  1558.  
  1559.    =>  !"string"  last command starting with "string".
  1560.  
  1561.  Completion:
  1562.  
  1563.    =>  tab complete command if first arg, filename otherwise.
  1564.  
  1565.    =>  esc-? or double tab list possible completions.
  1566.  
  1567.  Each line of input must be smaller than 1024 bytes which is more than
  1568.  sufficient for most applications. Lines can be continued on several
  1569.  lines provided carriage returns follow a `\' (as in standard
  1570.  shells).
  1571.  
  1572.  See also:
  1573.      append history, $, history
  1574.  
  1575. ?load
  1576. ?source
  1577.  
  1578.  The `load' command executes each line of the specified input file
  1579.  as if it had been typed in interactively. Files created by the 
  1580.  `save history' command can be `load'ed directly. Text files
  1581.  containing valid commands can be created and then executed by the 
  1582.  `load' command. Files being `load'ed may themselves contain 
  1583.  `load' commands. See `comment' for information about comments in
  1584.  command scripts. The `load' command is recursive so it can be
  1585.  nested. The only limitation is the I/O stack which has a default
  1586.  capacity of 32. This value can be easily changed at compilation time
  1587.  of the program.
  1588.  
  1589.  The current working directory always returns to the value in effect
  1590.  before the loaded script was called. This is valid for nested 
  1591.  `load' commands too.
  1592.  
  1593.  In order to avoid confusion between data files and script files we
  1594.  strongly recommand you to stick to the conventional ".ft" extension
  1595.  for your script files.
  1596.  
  1597.  Syntax:
  1598.      load "filename.ft"
  1599.  
  1600.  A `load' command is also performed implicitly on any filenames
  1601.  given as arguments to `fudgit', when called from your UNiX
  1602.  session. These are loaded and executed in the order specified, and
  1603.  then FUDGIT exits.
  1604.  
  1605.  See also:
  1606.      set comment, exec, startup, append history, append macros
  1607.  
  1608. ?lock
  1609. ?constant
  1610.  
  1611.  Variables can be turned into constants using the `lock' command.
  1612.  Once a variable is `lock'ed, any assignment trying to change its
  1613.  value will result in a parsing error. This is valid for both scalar
  1614.  and string variables. It is not an error to try to lock a constant. A
  1615.  warning message will be given though. However, trying to lock an
  1616.  unexisting variable or something else than a constant or variable will
  1617.  result in an error.
  1618.  
  1619.  Syntax:
  1620.      lock "var-list"
  1621.  
  1622.  See also:
  1623.      C, cmode, unlock
  1624.  
  1625. ?ls
  1626.  
  1627.  The command `ls' calls ``/bin/ls -FC''. If any arguments are
  1628.  given, those are passed to ``/bin/ls -FC''. Wild card characters are
  1629.  possible since expansion is done by a Bourne shell.
  1630.  
  1631.  Syntax:
  1632.      ls "ls-argument-list"
  1633.  
  1634.  Examples:
  1635.       ls p* test?
  1636.       ls -l datafile
  1637.       ls -l *.data
  1638.  
  1639.  See also:
  1640.      system, alias
  1641.  
  1642. ?macro
  1643.  
  1644.  The `macro' command allows the user to define macros. Macros can
  1645.  be embedded, but another macro cannot be defined from within a macro,
  1646.  mainly because of their common way to refer to arguments. The name of
  1647.  the macro followed by the number of arguments required must be given.
  1648.  The maximum number of arguments a macro can have is 16. An exclamation
  1649.  mark in the macro name will indicate that the macro name can be
  1650.  abbreviated and that the characters following the exclamation point
  1651.  are optional. Macros are only recognized in the fitting mode. The
  1652.  total length of each macro is limited to 2048 bytes in size. Macros
  1653.  can be nested to a maximum of 32. Macros are only recognized from the
  1654.  fitting mode.
  1655.  
  1656.  Syntax:
  1657.      macro "macroname" "argument-number"
  1658.          "body of the macro"
  1659.      stop
  1660.  
  1661.  Example:
  1662.      # define a macro named fpl!ot (o, t, are optional)
  1663.      # requiring 3 arguments . Uses the plotting program gnuplot.
  1664.      # Syntax: fplot X Y YFIT
  1665.      # plot X Y with data points and X YFIT with solid line
  1666.      macro fpl!ot 3
  1667.          # save vectors in temp file (will be automatically removed on exit)
  1668.          save vec $1 $2 $3 $Tmp.fplot
  1669.          # plot second column with points and third with line
  1670.          pmode plot '$Tmp.fplot' us 1:2 wi point, 
  1671.             '$Tmp.fplot' us 1:3 wi line
  1672.      stop
  1673.  
  1674.  See also:
  1675.      append macros, show macros, load, startup, unmacro, alias, unalias
  1676.  
  1677. ?math
  1678.  
  1679.  The C-calculator mode math functions found in FUDGIT are very close
  1680.  to the corresponding functions found in the UNiX math library. Some
  1681.  other functions, not found in the math library, are also part of
  1682.  FUDGIT. Most of the numerically unstable functions (i.e. ln, log,
  1683.  exp,...) check for both an argument out of range and a value out of
  1684.  domain at each call. All math functions are double precision and can
  1685.  only be called from the C-calculator mode, or by using the `let'
  1686.  command from the fitting mode. These functions are also available in
  1687.  the conditional statements of the fitting mode `if' and 
  1688.  `while', since these statements are C-calculator mode statements,
  1689.  although part of fitting mode constructions.
  1690.  
  1691. ?math abs
  1692. ?abs
  1693.  
  1694.  The `abs()' function returns the absolute value of its argument. 
  1695.  
  1696. ?math acos
  1697. ?acos
  1698.  
  1699.  The `acos()' function returns the arc cosine (inverse cosine) of
  1700.  its argument. `acos()' returns its argument in radians.
  1701.  
  1702. ?math acosh
  1703. ?acosh
  1704.  
  1705.  The `acosh()' function returns the positive (principal) hyperbolic
  1706.  arc cosine (inverse cosine) of its argument.
  1707.  
  1708. ?math asin
  1709. ?asin
  1710.  
  1711.  The `asin()' function returns the arc sine (inverse sine) of its
  1712.  argument. `asin()' returns its argument in radians.
  1713.  
  1714. ?math asinh
  1715. ?asinh
  1716.  
  1717.  The `asinh()' function returns the hyperbolic arc sine (inverse
  1718.  sine) of its argument.
  1719.  
  1720. ?math atan
  1721. ?atan
  1722.  
  1723.  The `atan()' function returns the arc tangent (inverse tangent) of
  1724.  its argument. `atan()' returns its argument in radians.
  1725.  
  1726. ?math atan2
  1727. ?atan2
  1728.  
  1729.  The `atan2(y, x)' function returns the arc tangent (inverse
  1730.  tangent) of the ratio of its arguments (y/x). `atan2()' returns
  1731.  its argument in radians. The signs of y and x are used to
  1732.  determine the quadrant.
  1733.  
  1734. ?math atanh
  1735. ?atanh
  1736.  
  1737.  The `atanh()' function returns the hyperbolic arc tangent (inverse
  1738.  tangent) of its argument.
  1739.  
  1740. ?math besj0
  1741. ?besj0
  1742.  
  1743.  The `besj0()' function returns the j0th Bessel function of its
  1744.  argument, i.e it returns the zero^th order Bessel function of the
  1745.  first kind. `besj0()' expects its argument to be in radians.
  1746.  
  1747. ?math besj1
  1748. ?besj1
  1749.  
  1750.  The `besj1()' function returns the j1st Bessel function of its
  1751.  argument, i.e it returns the first order Bessel function of the first
  1752.  kind. `besj1()' expects its argument to be in radians.
  1753.  
  1754. ?math besjn
  1755. ?besjn
  1756.  
  1757.  The `besjn(n, x)' function returns the jnst Bessel function of its
  1758.  argument, i.e it returns the n^th order Bessel function of the
  1759.  first kind. `besjn()' expects its second argument to be in
  1760.  radians.
  1761.  
  1762. ?math besy0
  1763. ?besy0
  1764.  
  1765.  The `besy0()' function returns the y0th Bessel function of its
  1766.  argument, i.e it returns the zero^th order Bessel function of the
  1767.  second kind. `besy0()' expects its argument to be in radians.
  1768.  
  1769. ?math besy1
  1770. ?besy1
  1771.  
  1772.  The `besy1()' function returns the y1st Bessel function of its
  1773.  argument, i.e it returns the first order Bessel function of the second
  1774.  kind. `besy1()' expects its argument to be in radians.
  1775.  
  1776. ?math besyn
  1777. ?besyn
  1778.  
  1779.  The `besyn(n, x)' function returns the ynst Bessel function of its
  1780.  argument, i.e it returns the n^th order Bessel function of the
  1781.  second kind. `besyn()' expects its second argument to be in
  1782.  radians.
  1783.  
  1784. ?math cbrt
  1785. ?cbrt
  1786.  
  1787.  The `cbrt()' function returns the cubic root of its argument.
  1788.  
  1789. ?math ceil
  1790. ?ceil
  1791.  
  1792.  The `ceil()' function returns the smallest integer that is not
  1793.  less than its argument.
  1794.  
  1795. ?math cos
  1796. ?cos
  1797.  
  1798.  The `cos()' function returns the cosine of its argument. 
  1799.  `cos()' expects its argument to be in radians.
  1800.  
  1801. ?math cosh
  1802. ?cosh
  1803.  
  1804.  The `cosh()' function returns the hyperbolic cosine of its
  1805.  argument.
  1806.  
  1807. ?math cot
  1808. ?cot
  1809.  
  1810.  The `cot()' function returns the cotangent of its argument. 
  1811.  `cot()' expects its argument to be in radians.
  1812.  
  1813. ?math coth
  1814. ?coth
  1815.  
  1816.  The `coth()' function returns the hyperbolic cotangent of its
  1817.  argument.
  1818.  
  1819. ?math csc
  1820. ?csc
  1821.  
  1822.  The `csc()' function returns the cosecant of its argument. 
  1823.  `csc()' expects its argument to be in radians.
  1824.  
  1825. ?math csch
  1826. ?csch
  1827.  
  1828.  The `csch()' function returns the hyperbolic cosecant of its
  1829.  argument.
  1830.  
  1831. ?math erf
  1832. ?erf
  1833.  
  1834.  The `erf()' function returns the error function of its argument.
  1835.  The error function is defined as
  1836.  
  1837.     2/sqrt(pi) * integral from 0 to x of  exp(-t^2) dt 
  1838.  
  1839. ?math erfc
  1840. ?erfc
  1841.  
  1842.  The `erfc()' function returns `1 - erf()' where `erf()' is
  1843.  the error function of its argument. It is provided because of the
  1844.  extreme loss of relative accuracy if `erf(x)' is called for large
  1845.  x and the result subtracted from 1.0 (e.g., for x = 10, 12 places
  1846.  are lost).
  1847.  
  1848. ?math exp
  1849. ?exp
  1850.  
  1851.  The `exp()' function returns the exponential function of its
  1852.  argument (e raised to the power of its argument). Overflow is
  1853.  checked on all `exp()' operations.
  1854.  
  1855. ?math floor
  1856. ?floor
  1857.  
  1858.  The `floor()' function returns the largest integer not greater
  1859.  than its argument.
  1860.  
  1861. ?math hypoth
  1862. ?hypot
  1863.  
  1864.  The `hypot(x, y)' function returns sqrt(x*x+y*y) computed in such
  1865.  a way that underflow will not happen, and overflow occurs only if the
  1866.  final result deserves it.
  1867.  
  1868. ?math int
  1869. ?int
  1870.  
  1871.  The `int()' function returns the integer part of its argument,
  1872.  truncated toward zero. The returned value is still a double. This
  1873.  function is equivalent to trunc() is is kept for compatibility.
  1874.  
  1875. ?math interp
  1876. ?interp
  1877.  
  1878.  The `interp()' function returns an interpolated value of the
  1879.  function at the value of its argument. The functional relation is
  1880.  previously initialized using the fitting mode command `spline'.
  1881.  The interpolation is obtained from cubic splines. "Natural" (i.e.,
  1882.  the second derivative of the interpolating function at either or both
  1883.  the first and last point of the original data equal zero) cubic spline
  1884.  or specific first derivatives at the extreme points of the original
  1885.  data set are specified while initializing the process using `spline'
  1886.  command.
  1887.  
  1888.  See also:
  1889.      spline
  1890.  
  1891. ?math lgamma
  1892. ?lgamma
  1893.  
  1894.  The `lgamma()' function returns the natural logarithm of the gamma
  1895.  function of its argument. For an integer `n, lgamma(n+1) =
  1896.  ln(fac(n))' where fac is a factorial function.
  1897.  
  1898. ?math ln
  1899. ?ln
  1900.  
  1901.  The `ln()' function returns the natural logarithm (base e ) of
  1902.  its argument. Illegal argument is checked for.
  1903.  
  1904. ?math log
  1905. ?log
  1906.  
  1907.  The `log()' function returns the logarithm (base 10) of its
  1908.  argument.
  1909.  
  1910. ?math max
  1911. ?max
  1912.  
  1913.  The built-in function `max(x, y)' returns the maximum value of
  1914.  x and y. `max(x, max(y, z))' obviously returns the largest value
  1915.  of x, y, and z.
  1916.  
  1917. ?math min
  1918. ?min
  1919.  
  1920.  The built-in function `min(x, y)' returns the minimum value of
  1921.  x and y. `min(x, min(y, z))' obviously returns the smallest value
  1922.  of x, y, and z.
  1923.  
  1924. ?math rand
  1925. ?rand
  1926.  
  1927.  The `rand()' function returns a random number between [0,1).
  1928.  Depending on the machine on which it is compiled, it might use the
  1929.  extended 48 bits random number generator or less.
  1930.  
  1931. ?math rint
  1932. ?rint
  1933.  
  1934.  The `rint()' function returns the value of its argument rounded to
  1935.  the nearest integer.
  1936.  
  1937. ?math scan
  1938. ?scan
  1939.  
  1940.  This math function is a bit different from others in the fact that it
  1941.  handles strings and returns a number. In fact, the `scan(
  1942.  "String, Format")' function returns a double precision number as
  1943.  extracted from string "String" and according to string format 
  1944.  "Format". The format is built with the same rules `sscanf' uses.
  1945.  See man pages on `scanf(3)'. Note that the format must contain
  1946.  one active "%lf". An example might be of some help here, especially
  1947.  to show how to use `scan' in conjunction with C-calculator mode
  1948.  defined strings. `scan' is particularly helpful to extract numbers
  1949.  from filenames. Recall that strings are defined by double quotes as
  1950.  in standard C.
  1951.  
  1952.  At this point, it might be useful for you to know the "%[ ]" scanf
  1953.  construction. Let's go through some examples: `"%*[a-zA-Z]"'
  1954.  means to ignore the longest string matched so that it is composed of
  1955.  any letter; `"%*[^0-9]"' means to ignore the longest string
  1956.  matched so that it is NOT composed of any digit; `"%*[^_.]"'
  1957.  means to ignore the longest string matched so that it is not composed
  1958.  of characters `_' or `.'.
  1959.  
  1960.  Examples:
  1961.      # define a string called Testname
  1962.      let Testname = "dummy25.dat"
  1963.      # let y be the Neperian log of the number contained in that string
  1964.      let y = ln(scan(Testname, "%*[^0-9]%lf.dat"))
  1965.      # The following reads a number from stdin
  1966.      let input = scan(Read(), "%lf")
  1967.  
  1968.  See also:
  1969.      $, strings, C, cmode, quotes
  1970.  
  1971. ?math sec
  1972. ?sec
  1973.  
  1974.  The `sec()' function returns the secant of its argument. 
  1975.  `sec()' expects its argument to be in radians.
  1976.  
  1977. ?math sech
  1978. ?sech
  1979.  
  1980.  The `sech()' function returns the hyperbolic secant of its
  1981.  argument.
  1982.  
  1983. ?math sin
  1984. ?sin
  1985.  
  1986.  The `sin()' function returns the sine of its argument. 
  1987.  `sin()' expects its argument to be in radians.
  1988.  
  1989. ?math sinh
  1990. ?sinh
  1991.  
  1992.  The `sinh()' function returns the hyperbolic sine of its
  1993.  argument. `sinh()' expects its argument to be in radians.
  1994.  
  1995. ?math sqrt
  1996. ?sqrt
  1997.  
  1998.  The `sqrt()' function returns the square root of its argument.
  1999.  
  2000. ?math srand
  2001. ?srand
  2002.  
  2003.  The `srand()' function sets the seed of the random number
  2004.  generator. Its argument will always be truncated to an integer
  2005.  towards zero. `srand()' returns the truncated value.
  2006.  
  2007. ?math sum
  2008. ?sum
  2009.  
  2010.  The `sum' function returns the sum of the elements of the vector
  2011.  passed as an argument. Recall that vector are passed by pointers so
  2012.  that `y = sum(X^2)' is not legal. Instead, on must explicitly
  2013.  calculate
  2014.  
  2015.  # Given vector X, the following calculates the sum of X^2
  2016.  let X2 = X^2
  2017.  let y = sum(X2)
  2018.  
  2019.  in order to evaluate the sum. The `sum' function can be used to
  2020.  calculate basic statistics (mean, standard deviation, correlation, ...)
  2021.  and to do basic integration together with a spline-interp algorithm
  2022.  if the points are distant and the function smooth enough.
  2023.  
  2024.  See also:
  2025.      interp, spline
  2026.  
  2027. ?math tan
  2028. ?tan
  2029.  
  2030.  The `tan()' function returns the tangent of its argument. 
  2031.  `tan()' expects its argument to be in radians.
  2032.  
  2033. ?math tanh
  2034. ?tanh
  2035.  
  2036.  The `tanh()' function returns the hyperbolic tangent of its
  2037.  argument. `tanh()' expects its argument to be in radians.
  2038.  
  2039. ?math trunc
  2040. ?trunc
  2041.  
  2042.  The `trunc()' function returns the value of the argument when
  2043.  truncated towards zero.
  2044.  
  2045. ?pause
  2046. ?wait
  2047.  
  2048. The `pause' command displays any text associated with the command
  2049. and then waits a specified amount of time or until a carriage return is
  2050. pressed if the given time value is a negative integer. The `pause'
  2051. command is especially useful in conjunction with `load'ed files.
  2052.  
  2053.  Syntax:
  2054.      pause "value" "string(optional)"
  2055.  
  2056.  Examples:
  2057.      pause -1
  2058.      pause 3
  2059.      pause -1  Hit return to continue
  2060.      pause 10  This fits equation 4 to file $ReadFile.
  2061.  
  2062.  See also:
  2063.      echo, load
  2064.  
  2065. ?plot
  2066.  
  2067.  There exists no plot command as such. However two macros are
  2068.  predefined. One is `gnu!plot' to use with GNUPLOT and 
  2069.  `sgi!plot' to use with SGIPLOT. As they currently are, only two
  2070.  vectors can be passed to these macros. They serve like examples for
  2071.  building your own macros as well. See `show macros' to see the
  2072.  contents of the predefined macros of your site.
  2073.  
  2074.  See also:
  2075.      set plotting, special, macro, show macros
  2076.  
  2077. ?pmode
  2078.  
  2079.  The `pmode' command talks directly to the plotting program chosen
  2080.  with the `set plotting' command. Any command usually typed to the
  2081.  plotting routine is now valid. Furthermore, all the current variables,
  2082.  constants and their string counterparts can be expanded in the
  2083.  plotting mode. The fitting macros and aliases are not recognized in
  2084.  this mode. The command `fmode' permits the user to return from the
  2085.  plotting mode as does ^D when typed interactively. If `pmode'
  2086.  is called with trailing arguments, the remainder of the line will be
  2087.  passed to the plotting program while remaining in fitting mode. It is
  2088.  not an error to call `pmode' from the plotting mode. An warning
  2089.  message will be given though.
  2090.  
  2091.  If the plotting program is defined as a null string (`set plotting ""')
  2092.  then all command lines given in `pmode' will be ignored and
  2093.  warning messages will be given accordingly.
  2094.  
  2095.  Syntax:
  2096.      pmode "command(optional)"
  2097.  
  2098.  Examples:
  2099.      pmode
  2100.      pmode set nokey
  2101.      pmode plot "fudgfile" with lines
  2102.  
  2103.  See also:
  2104.      set plotting, set prompt-pm, special
  2105.  
  2106. ?print
  2107.  
  2108.  The `print' command is a C-calculator mode command that writes the
  2109.  value of a valid mathematical expression to a file selected by 
  2110.  `set output'. The default is "stdout". If there is more than one
  2111.  variable, a coma separated list must be given in which case each
  2112.  expression value will printed on the same line and separated by a tab.
  2113.  As with other number output commands, the output format is the one
  2114.  selected by the `set format' command. The default is "% 10.8e".
  2115.  The `print' command differs from `show variables' as follows:
  2116.  
  2117.    =>  `print' accepts any expression for indexing vector elements;
  2118.  
  2119.    =>  `print' requires a comma separated list;
  2120.  
  2121.    =>  `print' can be part of a function or procedure;
  2122.  
  2123.    =>  `print' can print strings provided they are in double
  2124.           quotes. This includes characters '\n', '\t', '\a', ...;
  2125.  
  2126.    =>  `print' does not append a newline.
  2127.  
  2128.    =>  `print' can print any mathemetical expression.
  2129.  
  2130.    =>  `print' is a C-calculator mode command.
  2131.  
  2132.  A simpler way to print variables to "stdout" from the C-calculator
  2133.  mode is to use the feature that any variable or coma separated list of
  2134.  variables given on the command line will be displayed, separated by tabs
  2135.  and appended with a newline character. Thus the construction @ifhelp
  2136.  
  2137.      set output stdout
  2138.      cmode
  2139.          print x, y, "n"
  2140.  
  2141.  is equivalent to
  2142.  
  2143.      cmode
  2144.          x, y
  2145.  
  2146.  typed in C-calculator mode (it becomes `let x,y' in fitting mode).
  2147.  The only difference between `print' and the automatic printing
  2148.  feature of C-calculator mode is that (1) `set output' only affects
  2149.  `print' command, and that (2) `print' does not automatically
  2150.  append a new line character.
  2151.  
  2152.  Syntax:
  2153.      print "coma-separated-var-list"
  2154.  
  2155.  Examples:
  2156.      cmode
  2157.          print x+2
  2158.          print String, x, y, z
  2159.          print "Warning aaa", "x = ", x, "n"
  2160.  
  2161.  See also:
  2162.      cmode, func, C, show table, show variable, math functions, quotes,
  2163.            set format, set output
  2164.  
  2165. ?proc
  2166.  
  2167.  The `proc' command is a C-calculator command used to define
  2168.  procedures. Procedures differs from functions in the fact that they do
  2169.  not return any value. The procedure arguments are passed and referred
  2170.  to the same way they are in functions. Keyword `proc' is a
  2171.  C-calculator mode command. The `show table' command can be used
  2172.  to list all the installed objects at a given time.
  2173.  
  2174.  Syntax:
  2175.      proc "procedurename"("proto-list(optional)") "cmode-line-statement"
  2176.  
  2177.  or
  2178.  
  2179.      proc "procedurename"("proto-list(optional)") {
  2180.           "cmode-statements"
  2181.      }
  2182.  
  2183.  Examples:
  2184.      # The following example will print the Fibonacci numbers lower than 1000
  2185.      cmode
  2186.          proc fib(x) { 
  2187.              a = 0 
  2188.              b = 1 
  2189.              while (b < x) { 
  2190.                  print b
  2191.                  c = b 
  2192.                  b += a 
  2193.                  a = c 
  2194.              } 
  2195.              print "n"
  2196.          } 
  2197.          # The following 'for' loop is equivalent to the preceding fib()
  2198.          proc fib2(x) {
  2199.              auto a,b,c        # This proc creates no global variable
  2200.  
  2201.              for(a=0,b=1;b<x;c=b,b+=a,a=c) {
  2202.                  print b
  2203.              }
  2204.              print "n"
  2205.          }
  2206.          fib(1000)  # A procedure as called from C-calculator mode.
  2207.     fmode
  2208.     let fib2(1000)  # A procedure as called from fitting mode.
  2209.     # A short example involving a vector
  2210.     set data 10
  2211.     let proc init(X, x) X=x
  2212.     let b=3
  2213.     let init(Y, 2/4 + b) # Shows that scalar can also be expressions.
  2214.  
  2215.  See also:
  2216.      return, cmode, C, func, auto, math, show table, install
  2217.  
  2218. ?pwd
  2219. ?cwd
  2220.  
  2221.  The `pwd' command prints the name of the working directory on
  2222.  the screen.
  2223.  
  2224.  Syntax:
  2225.      pwd
  2226.  
  2227.  See also:
  2228.      cd, ls
  2229.  
  2230. ?quit
  2231.  
  2232.  The commands `exit' and `quit' are equivalent and both will
  2233.  exit FUDGIT. On exit, all temporary files "/tmp/fudgitPID*" (note
  2234.  the wild card) will be erased. Here PID is the current process number.
  2235.  Moreover, if a plotting process is active, it will be sent a KILL
  2236.  signal. It is therefore a good habit to use the `$Tmp' string
  2237.  variable to build your temporary files.
  2238.  
  2239.  Syntax:
  2240.      quit
  2241.  
  2242.  See also:
  2243.      cmode, exit
  2244.  
  2245. ?quotes
  2246.  
  2247.  In the fitting mode, single and double quotes serve to indicate that
  2248.  all the characters between quotes should be taken as only one word,
  2249.  even if there are some blanks (tab or space) among them. The
  2250.  difference between single and double quotes is that within the former
  2251.  variable expansion (using `$') does not take place whereas it does in
  2252.  the latter. Quotes are not recognized between parentheses.
  2253.  
  2254.  In C-calculator mode, double quotes serve to indicate a string and
  2255.  parsing is done accordingly. As in C, double quotes can be included in
  2256.  a string using the `\' operator. Note that C special characters
  2257.  as '\n' for a newline, '\a' for a bell, '\t' for
  2258.  a tab, and so on, are recognized in a string. Single quotes have no
  2259.  special meanings. The only way to pass a `$' without expanding the
  2260.  following name is to escape the `$' with a `\'.
  2261.  
  2262.  Thus, a null string is given by `''' or `""' in the fitting
  2263.  mode and by `""' only in C-calculator mode.
  2264.  
  2265.  In pmode, both single and double quotes are freely passed to the
  2266.  plotting program. This is valid when trailing commands are are passed
  2267.  to `pmode', although FUDGIT implicitly stays in the fitting
  2268.  mode. Once again, expansion of a `$' followed by a string can be
  2269.  avoided using the escape character, i.e., by typing `\$'.
  2270.  
  2271.  See also:
  2272.      exec, set plotting, math function scan, print
  2273.  
  2274. ?read
  2275.  
  2276.  The `read' command is used to read data points from a file or from
  2277.  standard input. Each column is assigned to a given vector. Vectors not
  2278.  already allocated will automatically be. Range of values can be
  2279.  specified on any variable using the ["low":"high"] syntax. A
  2280.  ``*'' replacing a value will be taken as unexistent. Range of
  2281.  lines can be specified on any variable using the {"low":"high"}
  2282.  syntax. The last line range given will be the only one in effect. If
  2283.  the file name specified is `-' data will be read from the current
  2284.  standard input until the keyword `end' is found on a line by
  2285.  itself. The `read' - and the `load' commands are recursive
  2286.  functions so they can be nested insofar as you can understand what is
  2287.  going on. An assignment consists in a vector name and a column number
  2288.  separated by a colon. After a file has been successfully read, 
  2289.  `read' will put the name of the data file in string constant 
  2290.  `ReadFile'.
  2291.  
  2292.  Syntax:
  2293.      read "filename" "assignment[range](optional){linerange}(optional)" ...
  2294.  
  2295.  Examples:
  2296.      read file1 X:1[0:*] Y:2
  2297.      read file2 TIME:2{100:400}
  2298.      read - T:1 VALUE:2
  2299.      1    2.3
  2300.      2    4.7
  2301.      .    .
  2302.      .    .
  2303.      .    .
  2304.      end
  2305.  
  2306.  The first form will read positive values of the first column in vector
  2307.  X and corresponding values of the second in vector Y. The second
  2308.  will read the second column of file "file2" from line 100 to line
  2309.  400. The third will read T and "VALUE" from stdin. The
  2310.  assignment does not need to be in increasing order of column. Also
  2311.  note that the first column is 1.
  2312.  
  2313.  See also:
  2314.      exec, data
  2315.  
  2316. ?reinstall
  2317.  
  2318.  The `reinstall' command is used to perform the dynamical loading
  2319.  of a module that was already loaded. Typically, this is done after a
  2320.  module has been modified and recompiled. Refer to `install' for
  2321.  more detail.
  2322.  
  2323. ?return
  2324.  
  2325.  The C-calculator `return' keyword is used as in standard C to
  2326.  return from a function or a procedure. Contrary to C, `return'
  2327.  requires parentheses when returning a value from a function. It is an
  2328.  error to return a value from a procedure or to not return anything
  2329.  from a function. `return' is a C-calculator mode command.
  2330.  
  2331.  Syntax:
  2332.      return("expression")
  2333.      return
  2334.  See also:
  2335.      C, cmode, func, proc, auto
  2336.  
  2337. ?save
  2338.  
  2339.  Look under `append' command description.
  2340.  
  2341. ?set
  2342.  
  2343.  The `set' command sets a lot of options, as follows.
  2344.  
  2345. ?set comment
  2346.  
  2347.  The `set comment' command selects the character which will cause
  2348.  the rest of the line to be ignored. The default value is ``#''.
  2349.  Note that the effect of a comment character will be void if: (1) found
  2350.  somewhere between single quotes in fitting mode or (2) escaped with a
  2351.  `\'.
  2352.  
  2353.  Syntax:
  2354.      set comment "character"
  2355.  
  2356.  Example:
  2357.      set comment ?
  2358.  
  2359.  See also:
  2360.      show comment, comments
  2361.  
  2362. ?set data
  2363. ?data
  2364.  
  2365.  The `set data' command changes the effective size of vectors. All
  2366.  the vector arithmetic checks for index boundaries. The `data'
  2367.  constant is the higher bound of the check and necessarily the size of
  2368.  all vectors. Changing the `data' value does not change the values
  2369.  nor the capacity of vectors. It only changes the upper bound on the
  2370.  value the index can take. The `data' constant is also changed by
  2371.  the commands `read' and `exec', which set it to the number of
  2372.  valid data points read. Because the upper bound can never be higher
  2373.  than the effective capacity of vectors, a `data' value higher than
  2374.  the current `samples' value will be refused. See `set
  2375.  samples'. Typically, `set data' is used when one wants the
  2376.  C-calculator to generate (and plot) vectors. The `read' and 
  2377.  `exec' commands take care of adjusting it. `data' constant can also
  2378.  be changed from the C-calculator mode if the constant is 
  2379.  `unlock'ed. However, no check is made to ensure the given value is not
  2380.  higher than `sample' size, in which case a segmentation fault will
  2381.  crash the whole program. It is always safer to use `set data'.
  2382.  
  2383.  Syntax:
  2384.      set data "number"
  2385.  
  2386.  Example:
  2387.      set data 300
  2388.  
  2389.  See also:
  2390.      lock, unlock, read, exec, cmode
  2391.  
  2392. ?set debug
  2393. ?debug
  2394.  
  2395.  The `set debug' command puts the reading of `load'ed files in
  2396.  verbose mode, so that debugging is more easily done. All the commands,
  2397.  expanded macros and/or string variables are echoed as they are
  2398.  executed. There are some different debug levels at the present time:
  2399.  
  2400.    =>  0 clear all the debugging states.
  2401.  
  2402.    =>  1 echo the expanded lines as they are read. The command is
  2403.           parsed and comments are stripped out. This is most useful
  2404.           for debugging script files. History substitutions are shown.
  2405.  
  2406.    =>  2 display all command lines as they are read from the script.
  2407.  
  2408.    =>  3 display the line numbers of the ignored lines as they are
  2409.           read from datafiles.
  2410.  
  2411.    =>  4 echo command lines as they are passed to the math parser.
  2412.  
  2413.    =>  5 turn the math parser debugger on. To use this, the program
  2414.           must have been compiled with the YYDEBUG preprocessor
  2415.           variable on.
  2416.  
  2417.    =>  6 trace the flow of fitting mode `if' constructions.
  2418.  
  2419.  Debugging values are not exclusive so that more than one level
  2420.  can be turned on. Levels are subject to change.
  2421.  
  2422.  Syntax:
  2423.      set debug "value-list"
  2424.  
  2425.  Example:
  2426.      set debug 0 1 3
  2427.  
  2428.  See also:
  2429.      load
  2430.  
  2431. ?set error
  2432. ?error
  2433.  
  2434.  FUDGIT allows the user to select among different possible error
  2435.  checks to be made on each single mathematical operations. The
  2436.  `set error' command will set computational error checks as follows:
  2437.  
  2438.    =>  0: clear all computational error check bits.
  2439.  
  2440.    =>  1: check for `infinity' values.
  2441.  
  2442.    =>  2: check for `not a number' values.
  2443.  
  2444.    =>  3: check for `out of domain' math function errors.
  2445.  
  2446.    =>  4: check for `out of range' math function errors.
  2447.  
  2448.  Error checks are not exclusive and more than one can be specified on
  2449.  the command line. The default status has all error check levels
  2450.  activated (1 2 3 4).
  2451.  
  2452.  It is sometimes desirable to disable one of the checks. For example,
  2453.  the operation y = 1/sinh(x) will give a `out of range' error for
  2454.  large x ( > 709 on most machines), although y is in fact 0.
  2455.  If one uses `set error 0 1 2 3', then no error will be reported
  2456.  and y will be set to zero accordingly.
  2457.  
  2458.  Syntax:
  2459.      set debug "value-list"
  2460.  
  2461.  Example:
  2462.      set error 0 2 3
  2463.  
  2464.  See also:
  2465.      C, cmode
  2466.  
  2467. ?set expand
  2468. ?expand
  2469.  
  2470.  In interactive mode, history expansion and substitution will occur
  2471.  only if the `expand' variable is set. It is disabled using 
  2472.  `set noexpand'. The default is on.
  2473.  
  2474.  Syntax:
  2475.      set expand
  2476.  
  2477.  See also:
  2478.      set noexpand, history, line editing
  2479.  
  2480. ?set format
  2481. ?format
  2482.  
  2483.  The command `set format' will set the printf format for variables.
  2484.  Use only if you are sure of what you are doing. It defaults to
  2485.  ``% 10.8e". See `man printf(3)' if in doubt.
  2486.  
  2487.  Syntax:
  2488.      set format "string"
  2489.  
  2490.  Examples:
  2491.       set format %6.2lf
  2492.       set format "% .8g"
  2493.  
  2494.  See also:
  2495.      show, append
  2496.  
  2497. ?set function
  2498. ?function
  2499.  
  2500.  The `set function' command is perhaps the most crucial command in
  2501.  data fitting. It is used to select a built-in fitting function or to
  2502.  enter a user-defined function. The following fitting functions are
  2503.  available:
  2504.  
  2505.      NAME          DESCRIPTION             PARAMETERS REQUIRED
  2506.      ----          -----------             -------------------
  2507.      straight      Straight line           (2 parameters)
  2508.      sine          Sine series             (N parameters)
  2509.      cosine        Cosine series           (N parameters)
  2510.      legendre      Legendre series         (N parameters)
  2511.      polynomial    Power series            (N parameters)
  2512.      gauss         Gaussian series         (3N parameters)
  2513.      expo          Exponential series      (2N parameters)
  2514.      user          User-defined function   (N parameters)
  2515.  
  2516.  Assume a variable vector X and a parameter vector A then,
  2517.  the nonlinear gauss fitting function is a series of gaussians where
  2518.  
  2519.     f(X,A) = SUM (i=1,4,7,...,N) of A[i] * exp(-((X - A[i+1])/A[i+2])^ 2).
  2520.  
  2521.  
  2522.  The nonlinear expo function is a series of exponentials where
  2523.  
  2524.     f(X,A) = SUM (1=1,3,...,N) of A[i] * exp(X*A[i+1]).
  2525.  
  2526.  
  2527.  For a user-defined function, the `set function user' will prompt
  2528.  for more input. The following input is related to the variable to
  2529.  fit. For purposes of clarity, let's say that we have to fit vectors
  2530.  `X Y DY'. This requires a fit function `YFIT' (the name is
  2531.  made from the dependent variable appended with `FIT') and all the
  2532.  partial derivatives `DYFITD1, DYFITD2, ..., DYFITDN' taken with
  2533.  respect to the parameters n=1,... N. All these functions are
  2534.  defined one per line as in the case of a macro until a `stop' is
  2535.  entered. Temporary variables are permitted. `set function user'
  2536.  actually defines a C-calculator mode macro that will be executed
  2537.  before each iteration of the fit. Therefore the complete C-calculator
  2538.  mode grammar is fully supported here. Temporary vectors can thus be
  2539.  used to speed up the calculation.
  2540.  
  2541.  The C-calculator macro can be a simple call to a predefined procedure.
  2542.  When defined so, the parsing does not have to be done at each iteration,
  2543.  and a slightly faster process should result.
  2544.  
  2545.  Example:
  2546.     # read column 1, 2 and 3 of file "file"
  2547.     read file T:1 R:2 DR:3
  2548.     # make a three parameter fit
  2549.     set parameter K 3
  2550.     # this is a linear fit; use singular value decomposition
  2551.     set method svd_fit
  2552.     # enter my function
  2553.     set function user
  2554.         RFIT = K[1] + K[2]*T^0.5 + K[3]*T^1.5
  2555.         DRFITD1 = 1
  2556.         DRFITD2 = T^0.5
  2557.         DRFITD3 = T^1.5
  2558.     stop
  2559.     fit T R DR
  2560.  
  2561.  The vector `RFIT' will contain the fitted function. The difference
  2562.  between the fit and real data can be obtained right away by defining a
  2563.  vector
  2564.  
  2565.    let RDIFF = R - RFIT
  2566.  
  2567. that can be plotted with respect to `T'.
  2568.  
  2569.  The same thing is done for nonlinear fit with the exception that the
  2570.  partial derivatives of the function with respect to the parameters
  2571.  will contain reference to some parameter(s). (This is precisely the
  2572.  meaning of nonlinear here).
  2573.  
  2574.  There is virtually no restriction on the number of parameters (memory
  2575.  is the sole limitation: `set parameter' command allocates a
  2576.  matrix of `parameters' X `samples' ). The only conditions are
  2577.  that a linear regression must have 2 parameters defined (this is
  2578.  obvious) and the built-in nonlinear functions must be modulo 3 for the
  2579.  series of gaussians and modulo 2 for the series of exponentials.
  2580.  
  2581.  See also:
  2582.      fit, set method, adjust, proc, auto
  2583.  
  2584. ?set input
  2585. ?input
  2586.  
  2587.  The `set input' command selects the file for the input of the
  2588.  C-calculator mode `Read' and `vread' command. The string 
  2589.  "stdin" is valid as a filename. If the selected file does not exist or
  2590.  cannot be read, an error message will be given and the value will go
  2591.  back to the default value, which is "stdin".
  2592.  
  2593.  Syntax:
  2594.      set input "filename"
  2595.  
  2596.  See also:
  2597.      Read, vread
  2598.  
  2599. ?set iteration
  2600. ?iteration
  2601.  
  2602.  The `set iteration' command permits the user to change the
  2603.  iteration number for the Marquardt-Levenberg nonlinear fitting method.
  2604.  See `set function'. The default value is 10. However, the fitting
  2605.  process will stop if there is no difference in chi^2 for two
  2606.  consecutive iterations. However, a negative value will force to
  2607.  iterate up to the absolute value of that number, without checking for
  2608.  convergence.
  2609.  
  2610.  Syntax:
  2611.      set iteration "value"
  2612.  
  2613.  Example:
  2614.      set iteration 3
  2615.  
  2616.  See also:
  2617.      fit, set method, set function
  2618.  
  2619. ?set method
  2620. ?method
  2621.  
  2622.  The `set method' command allows the user to select the fitting
  2623.  method to be used when calling the `fit' command. The following
  2624.  methods are available:
  2625.  
  2626.      NAME         DESCRIPTION
  2627.      ----         -----------
  2628.      ls_reg       least square linear regression (2 parameters)
  2629.      lad_reg      least absolute deviation linear regression (2 parameters)
  2630.      ls_fit       general least square linear fit using QR decomposition
  2631.      svd_fit      general least square linear fit using singular value
  2632.                    decomposition
  2633.      ml_fit       general least square nonlinear fit using
  2634.                    Marquardt-Levenberg method
  2635.  
  2636.  Among them, only `ml_fit' and ls_fit depends on `iteration'
  2637.  and `adjust'.
  2638.  
  2639.  For all methods except `lad_reg', the value of chi^2 will be put
  2640.  in the scalar constant `chi2'. In the case of `lad_reg', %chi^2
  2641.  will contain the average absolute deviation.
  2642.  
  2643.  Syntax:
  2644.      set method "method"
  2645.  
  2646.  Example:
  2647.      set method svd
  2648.  
  2649.  See also:
  2650.      fit, set iteration, set function
  2651.  
  2652. ?set noexpand
  2653. ?noexpand
  2654.  
  2655.  The `set noexpand' command disallows history expansion on the
  2656.  interactive command line.
  2657.  
  2658.  Syntax:
  2659.      set noexpand
  2660.  
  2661.  See also:
  2662.      set expand
  2663.  
  2664. ?set output
  2665. ?output
  2666.  
  2667.  The `set output' command selects the file for the output of the
  2668.  C-calculator mode `print' command. The strings "stdout" and
  2669.  "stderr" are both valid as a filename. If the selected file
  2670.  already exists, it will be overwritten with no warning. The default
  2671.  value is "stdout".
  2672.  
  2673.  Syntax:
  2674.      set output "filename"
  2675.  
  2676.  See also:
  2677.      print
  2678.  
  2679. ?set pager
  2680. ?pager
  2681.  
  2682.  The `set pager' command allows the user to select a pager. A pager
  2683.  is the program that is called when the structure to be displayed has
  2684.  more than 24 elements. The default pager is (1) the environment
  2685.  variable PAGER if it exists or (2) "/usr/?/more" (path depends on
  2686.  system) if not. If `pager' is defined to a null string (`""'),
  2687.  then no pager will be used.
  2688.  
  2689.  Syntax:
  2690.      set pager "string"
  2691.  
  2692.  Example:
  2693.      set pager "more -c"
  2694.  
  2695.  See also:
  2696.      show, show pager
  2697.  
  2698. ?set parameters
  2699. ?parameters
  2700.  
  2701.  The command `set parameters' will fix the parameter name and
  2702.  size. Since the set of parameters is a kind of vector, parameter name
  2703.  cannot contain lower case letters. Parameters are initialized to
  2704.  zero. A built-in scalar constant called `param' contains the
  2705.  number of parameters at all time.
  2706.  
  2707.  Syntax:
  2708.      set parameters "parameter-name" "size"
  2709.  
  2710.  Example:
  2711.      # set the vector D of size 3 to be determined by the fit.
  2712.      set parameters D 3
  2713.  
  2714.  See also:
  2715.      show parameters, show setup
  2716.  
  2717. ?set plotting
  2718. ?plotting
  2719.  
  2720.  The `set plotting' command changes the default plotting program
  2721.  used by the plotting mode. The default is GNUPLOT but this can be
  2722.  changed to any plotting program that can be driven from stdin. A
  2723.  maximum of 16 arguments can be passed when the program is first
  2724.  called. Changing the plotting program will send a KILL signal to the
  2725.  existing plotting program (if any). If the plotting program is set to
  2726.  a null string (`""'), FUDGIT will ignore all the plotting
  2727.  commands and warning messages will be given. Setting the plotting
  2728.  program to a file that cannot be found or executed will result in an
  2729.  error at the first `pmode' call.
  2730.  
  2731.  Syntax:
  2732.      set plotting "command"
  2733.  
  2734.  Examples:
  2735.      set plotting "/usr/local/bin/sgiplot -p"
  2736.      set plotting /usr/local/bin/gnuplot
  2737.  
  2738.  See also:
  2739.      show plotting
  2740.  
  2741. ?set prompts
  2742. ?prompts
  2743.  
  2744.  All three FUDGIT prompts can be changed by the `set' command.
  2745.  The name of the prompts are:
  2746.  
  2747.    =>  `prompt-cm' for the C-calculator mode prompt
  2748.           (default: "cmode> ";
  2749.  
  2750.    =>  `prompt-fm' for the fitting mode prompt
  2751.           (default: "fudgit> ";
  2752.  
  2753.    =>  `prompt-pm' for the plotting mode prompt
  2754.           (default: "pmode> ".
  2755.  
  2756.  A null string `""' (i.e., two consecutive quotes) can be given to
  2757.  any of these.
  2758.  
  2759.  Syntax:
  2760.      set prompt-cm "string"
  2761.      set prompt-fm "string"
  2762.      set prompt-pm "string"
  2763.  
  2764.  See also:
  2765.      show prompts
  2766.  
  2767. ?set samples
  2768. ?samples
  2769.  
  2770.  The command `set samples' changes the current capacity of the
  2771.  fitting program. Typically, `samples' is set at the beginning of a
  2772.  session since all the existing vectors and variables are erased on
  2773.  this call. The default setting is 4000 points.
  2774.  
  2775.  Syntax:
  2776.      set samples "value"
  2777.  
  2778.  Example:
  2779.      set samples 6000
  2780.  
  2781.  See also:
  2782.      set data, cmode, let, lock
  2783.  
  2784. ?set vformat
  2785. ?vformat
  2786.  
  2787.  The command `set vformat' will set the sprintf format used for the
  2788.  expansion of scalar variables by the expansion operator `$'. Use
  2789.  only if you are sure of what you are doing. It defaults to ``%.3lg''.
  2790.  See `man printf(3)' if in doubt.
  2791.  
  2792.  Syntax:
  2793.      set vformat "string"
  2794.  
  2795.  Examples:
  2796.      set vformat %6.2lf
  2797.      set vformat "%.4lg"
  2798.  
  2799.  See also:
  2800.      $, cmode, C
  2801.  
  2802. ?shell
  2803.  
  2804.  The `shell' command starts a shell according to your SHELL
  2805.  environment variable. It is equivalent to `system' command. Refer
  2806.  to the latter for details.
  2807.  
  2808. ?show
  2809.  
  2810.  The `show' command is used to see the chosen options or to look at
  2811.  any defined vectors, parameters or variables.
  2812.  
  2813.  See also:
  2814.      set, echo
  2815.  
  2816. ?show comment
  2817.  
  2818.  The `show comment' command echoes the current comment escape
  2819.  character.
  2820.  
  2821.  Syntax:
  2822.      show comment
  2823.  
  2824.  See also:
  2825.      set comment, comments
  2826.  
  2827. ?show data
  2828.  
  2829.  The `show data' command displays the current value of `data'
  2830.  constant. Left for compatibility.
  2831.  
  2832.  Syntax:
  2833.      show data
  2834.  
  2835.  See also:
  2836.      set data, lock, unlock, set samples
  2837.  
  2838. ?show debug
  2839.  
  2840.  The `show debug' command displays the current value of the 
  2841.  `debug' variable. The value is displayed in octal since the
  2842.  `set debug' n command turns on the n^th bit of this number.
  2843.  
  2844.  Syntax:
  2845.      show debug
  2846.  
  2847.  See also:
  2848.      set debug
  2849.  
  2850. ?show error
  2851.  
  2852.  The `show error' command displays the current value of the 
  2853.  `error' computational check variable. The value is displayed in octal
  2854.  since the `set error' n command turns on the n^th bit of
  2855.  this number.
  2856.  
  2857.  Syntax:
  2858.      show error
  2859.  
  2860.  See also:
  2861.      set error
  2862.  
  2863. ?show input
  2864.  
  2865.  The `show input' command shows the filename selected for the
  2866.  input of the C-calculator mode `Read' and `vread' command.
  2867.  The default value is "stdin"
  2868.  
  2869.  Syntax:
  2870.      show input
  2871.  
  2872.  See also:
  2873.      set input, Read, vread
  2874.  
  2875. ?show iterations
  2876.  
  2877.  The `show iteration' command displays the current value of
  2878.  `iteration' variable.
  2879.  
  2880.  Syntax:
  2881.      show iteration
  2882.  
  2883.  See also:
  2884.      set iteration, set method
  2885.  
  2886. ?show fit
  2887.  
  2888.  The `show fit' command displays the different quantities relevant
  2889.  to the current fitting method. Typical examples are chi^2, the 
  2890.  covariance matrix, the curvature matrix, correlation factor, etc...
  2891.  
  2892.  Syntax:
  2893.      show fit
  2894.  
  2895.  See also:
  2896.      fit, set parameters, set function, set method
  2897.  
  2898. ?show format
  2899.  
  2900.  The `show format' command displays the current value of
  2901.  `format' variable. The `format' string is used when
  2902.  displaying any number on the screen. Refer to printf(3) of
  2903.  the UNiX manual.
  2904.  
  2905.  Syntax:
  2906.      show format
  2907.  
  2908.  See also:
  2909.      set format, show
  2910.  
  2911. ?show function
  2912.  
  2913.  The command `show function' displays the current function type. If
  2914.  the function type is `user', then the user-defined function will
  2915.  be displayed.
  2916.  
  2917.  Syntax:
  2918.      show function
  2919.  
  2920.  See also:
  2921.      set function, show setup, fit, math
  2922.  
  2923. ?show macros
  2924.  
  2925.  If called with an argument, the `show macros' command will display
  2926.  the specified macro. Otherwise, all currently defined macros will be
  2927.  displayed. The selected `pager' is called if the command is given
  2928.  in interactive mode (at the command line prompt).
  2929.  
  2930.  Syntax:
  2931.      show macros "macroname"(optional)
  2932.  
  2933.  See also:
  2934.      set pager, save macros, alias
  2935.  
  2936. ?show memory
  2937. ?memory
  2938.  
  2939.  The `show memory' function will display the current state of
  2940.  memory consumption of the program. All sizes are given in bytes. It
  2941.  uses a direct call to mallinfo(3). The arena is the size of memory
  2942.  requested by the process to the kernel. It is then split in different
  2943.  blocks shared among the internal matrices and user's vectors, macros,
  2944.  functions, procedures, variables and history.
  2945.  
  2946.  Syntax:
  2947.      show memory
  2948.  
  2949.  See also:
  2950.      free, show table
  2951.  
  2952. ?show method
  2953.  
  2954.  The `show method' command displays the current value of the
  2955.  fitting `method'. It contains "none" by default.
  2956.  
  2957.  Syntax:
  2958.      show method
  2959.  
  2960.  See also:
  2961.      set method, fit, set function
  2962.  
  2963. ?show output
  2964.  
  2965.  The `show output' command shows the filename selected
  2966.  for the output of the C-calculator mode `print' command. 
  2967.  The default value is "stdout"
  2968.  
  2969.  Syntax:
  2970.      show output
  2971.  
  2972.  See also:
  2973.      set output, print
  2974.  
  2975. ?show pager
  2976.  
  2977.  The `show pager' command displays the current value of the
  2978.  `pager' program. 
  2979.  
  2980.  Syntax:
  2981.      show pager
  2982.  
  2983.  See also:
  2984.      set pager, environment, show
  2985.  
  2986. ?show parameters
  2987.  
  2988.  The command `show parameters' will display the parameter values on
  2989.  the screen. If the number of parameters is larger than 24, then the
  2990.  selected `pager' will be called if the command is given in
  2991.  interactive mode (at the command line prompt). As with `append'
  2992.  and `save parameters', `show parameter' can accept optional
  2993.  variable or constant (either string or scalar) list of names, in which
  2994.  case the value of the given variables will be displayed along with the
  2995.  parameter values.
  2996.  
  2997.  Syntax:
  2998.      show parameters "variable-list(optional)"
  2999.  
  3000.  See also:
  3001.      set pager, set parameters, save parameters, show fit
  3002.  
  3003. ?show plotting
  3004.  
  3005.  The `show plotting' command displays the current value of the
  3006.  `plotting' program. 
  3007.  
  3008.  Syntax:
  3009.      show plotting
  3010.  
  3011.  See also:
  3012.      set plotting, startup, pmode
  3013.  
  3014. ?show prompts
  3015.  
  3016.  The `show prompts' command displays the current values of the
  3017.  different mode `prompts'. 
  3018.  
  3019.  Syntax:
  3020.      show prompt-cm
  3021.      show prompt-fm
  3022.      show prompt-pm
  3023.  
  3024.  See also:
  3025.      set prompt, startup
  3026.  
  3027. ?show samples
  3028.  
  3029.  The `show samples' command displays the current value of the 
  3030.  `samples' variable. Recall that although `data' is responsible for
  3031.  the visible part of all vectors, vectors all have a fixed allocated
  3032.  length of `samples' long. Any change to `samples' through 
  3033.  `set samples' frees all the existing vectors.
  3034.  
  3035.  Syntax:
  3036.      show samples
  3037.  
  3038.  See also:
  3039.      set samples, set data, cmode
  3040.  
  3041. ?show setup
  3042. ?setup
  3043.  
  3044.  The command `show setup' will show some values of the program,
  3045.  such as the last data filename read, the number of data points, 
  3046.  current capacity, current comment character, current iteration number,
  3047.  current plotting program, etc. Left for compatibility.
  3048.  
  3049.  Syntax:
  3050.      show setup
  3051.  
  3052.  See also:
  3053.      set comments
  3054.  
  3055. ?show table
  3056. ?table
  3057.  
  3058.  The command `show table' displays the current lookup table of the
  3059.  C-calculator mode parser. It shows all current variables, numbers,
  3060.  vectors and functions included in the internal table. It also shows
  3061.  the state of the internal machine (C interpreter), stack and frame
  3062.  used in the C-calculator. This is used mainly for debugging or to
  3063.  prevent stack or machine code overflow.
  3064.  
  3065.  Syntax:
  3066.      show table
  3067.  
  3068.  See also:
  3069.      free, show memory, cmode
  3070.  
  3071. ?show variables
  3072.  
  3073.  Any constants or variables can be displayed on the screen. 
  3074.  The `show variable' command differs from `print' as follows:
  3075.  
  3076.    =>  `show variables' only accepts integers for indexing
  3077.           vector elements;
  3078.  
  3079.    =>  `show variables' requires a blank separated list;
  3080.  
  3081.    =>  `show variables' cannot be part of a function or procedure.
  3082.  
  3083.  As it has been mentioned previously, this is due to the different
  3084.  types of parsing between the C-calculator and fitting modes. As with
  3085.  all other number displaying commands, the printing format is
  3086.  always the one selected by the `set format' command.
  3087.  
  3088.  Syntax:
  3089.      show variables "variable-list"
  3090.  
  3091.  Example:
  3092.      show variables x X[2] Y[2] DY[2] time
  3093.  
  3094.  See also:
  3095.      print, save variables, show table, show vectors, cmode
  3096.  
  3097. ?show vectors
  3098.  
  3099.  Any vector or number of vectors can be seen on the screen. If the size
  3100.  of vectors is larger than 24, the selected `pager' will be called
  3101.  if the command is given in interactive mode (at the command line
  3102.  prompt).
  3103.  
  3104.  Syntax:
  3105.      show vectors "VECTOR-list"
  3106.  
  3107.  Example:
  3108.      show vectors X Y DY
  3109.  
  3110.  See also:
  3111.      set pager, append vectors, read, cmode, let
  3112.  
  3113. ?show vformat
  3114. ?vformat
  3115.  
  3116.  The command `show vformat' will display the printf format used
  3117.  for the expansion of scalar variables by the expansion operator `$'.
  3118.  Refer to the printf(3) description in the UNiX manual for more details.
  3119.  
  3120.  Syntax:
  3121.      show vformat
  3122.  
  3123.  See also:
  3124.      $, cmode, C, set vformat
  3125.  
  3126. ?smooth
  3127.  
  3128.  The `smooth' command uses a gaussian windowing function (low-pass
  3129.  filter) on a Fourier transform loop in order to smooth the given
  3130.  vector. The windowing function is exp(-(f/(sigma X f_max))^2)
  3131.  where f_max is equal to half of the smallest power of 2 larger
  3132.  than the number of data points `data'. Variable f is the
  3133.  frequency that ranges from 0 to f_max. More likely, the smoothing
  3134.  factor is a non null positive real number from the (0, 1] interval. A
  3135.  smoothing factor sigma >= 1 leaves the vector unchanged.
  3136.  
  3137.  The number of data points `data' needs not to be a power of 2.
  3138.  
  3139.  To be used with discernment!
  3140.  
  3141.  Syntax:
  3142.      smooth "sigma" "in-VECTOR" "out-VECTOR"
  3143.  
  3144.  See also:
  3145.      fft, invfft, cmode, C
  3146.  
  3147. ?special
  3148.  
  3149.  The following special commands are left for debugging or macro purposes.
  3150.  They start with an underscore to avoid mistakes and remind of their
  3151.  special character.
  3152.  
  3153.  `_killplot' will kill the current plotting program.
  3154.  
  3155.  Syntax:
  3156.      _killplot
  3157.  
  3158.  `_dumplot' will send the following vectors in the plotting
  3159.  program pipe. This is only useful if the current plotting program
  3160.  accept data from its stdin. `_dumplot' can accept up to 16
  3161.  arguments.
  3162.  
  3163.  Syntax:
  3164.      _dumplot "VECTOR-list"
  3165.  
  3166.  Example:
  3167.      _dumplot X Y DY
  3168.  
  3169.  See also:
  3170.      macro, show macros, plot
  3171.  
  3172. ?spline
  3173.  
  3174.  The `spline' function initializes the internal table for the
  3175.  calculation of interpolated values using cubic spline method.
  3176.  Interpolated values are obtained from calls to the C-calculator math
  3177.  function `interp()'. The value of the first derivative at the
  3178.  first and last data points can be specified by optional arguments. If
  3179.  not specified, or if one of the optional arguments is an asterisk `*',
  3180.  then a "natural" cubic spline is assumed in which case the
  3181.  interpolated curve is such that the second derivative at the extreme
  3182.  points (or one of them) is null. The asterisk is more likely to be used
  3183.  in cases where the user would like to specify the first derivative at
  3184.  the last point only. The independent vector must be such that its
  3185.  value increases monotonically.
  3186.  
  3187.  Syntax:
  3188.      spline "indep-VECTOR" "dep-VECTOR" "y1(optional)" "yn(optional)"
  3189.  
  3190.  Example:
  3191.      # Read vectors having a functional relation Y = F(X) from file "datafile"
  3192.      read datafile X:1 Y:2
  3193.      # Initialize the spline (as being natural)
  3194.      spline X Y
  3195.      # Save extreme values
  3196.      let from = X[1]; to = X[data]
  3197.      # Say there were data=10 points and you want 100
  3198.      set data 100
  3199.      # Rebuild X vector
  3200.      # First build X ranging [0, 1]
  3201.      let x=0; X=x++; tmp=data-1; X/=tmp
  3202.      # Then from 'from' to 'to': from + (to - from)*X
  3203.      let tmp=(to-from); X = from + X*tmp
  3204.      # Rebuild Y vector possibly containing original values as a subset
  3205.      let Y = interp(X)
  3206.      # Note that any value can be asked for
  3207.      let interp(2.34*pi)
  3208.  
  3209.  See also:
  3210.      math interp
  3211.  
  3212. ?startup
  3213.  
  3214.  If a file ".fudgitrc" exists in your home directory, it will be
  3215.  automatically loaded at startup time of the program. This is useful if
  3216.  one wants to include his own macros or have his own preferences loaded
  3217.  to FUDGIT. This file is loaded for both interactive use (`fudgit')
  3218.  and batch use (`fudgit "script1" "script2"...').
  3219.  
  3220.  Examples:
  3221.      set plotting /usr/local/bin/sgiplot
  3222.      set prompt-pm ""
  3223.      set comment ?
  3224.      set samples 10000
  3225.  
  3226.  A file called ".hist_fudgit" is will be created in your home
  3227.  directory in order to keep history between calls of FUDGIT. The
  3228.  number of events is determined at compilation time and defaults to 52.
  3229.  
  3230.  See also:
  3231.      environment, alias, set plotting, set prompt
  3232.  
  3233. ?stop
  3234.  
  3235.  The command `stop' is used to terminate a macro or a fitting
  3236.  function defined by the user. However, it can also be used in a script
  3237.  file in order to stop execution at a certain point. In this case, an
  3238.  warning message will report that `stop' is being used outside a
  3239.  macro or function and the file from which the command was found will
  3240.  be considered as at the end of file (EOF).
  3241.  
  3242.  See also:
  3243.      macro, set function
  3244.  
  3245. ?strings
  3246. ?Strings
  3247.  
  3248.  FUDGIT has a set of functions returning string objects. These are
  3249.  made available to deal with filename construction, or to read from
  3250.  standard input. To be consistent with string type, string functions
  3251.  are named with both lower case and upper case letters.
  3252.  
  3253.  Strings can be added or subtracted in the C-calculator mode. String
  3254.  addition "s1" + "s2" simply concatenates strings "s2" to
  3255.  string "s1". String subtraction "s1" - "s2" removes 
  3256.  "s2" from the end of "s1". Note that the wild card `?' is supported
  3257.  in string subtractions.
  3258.  
  3259. ?Strings DirName
  3260. ?strings DirName
  3261. ?DirName
  3262.  The string function `DirName' returns the directory name as extracted
  3263.  from the filename given as an argument.
  3264.  
  3265.  Syntax:
  3266.      Dirname("String")
  3267.  
  3268.  See also:
  3269.      string functions FileName, Scan, Read
  3270.  
  3271. ?strings FileName
  3272. ?Strings FileName
  3273. ?FileName
  3274.  
  3275.  The string function `FileName' strips the leading directory names
  3276.  of the filename given as an argument. Note that the UNiX command:
  3277.  
  3278.      basename "File" "Extension"
  3279.  
  3280.  is equivalent to the FUDGIT command:
  3281.  
  3282.      FileName("File") - "Extension"
  3283.  
  3284.  so that filename constructions can be made in `foreach' loop
  3285.  for example.
  3286.  
  3287.  Syntax:
  3288.      FileName("String")
  3289.  
  3290.  Examples:
  3291.      foreach File in ls /usr/machin/data/*.32
  3292.          read $File X:1 Y:2{2:23}
  3293.          # Some commands
  3294.          .
  3295.          .
  3296.          # let File be the filename only, less the ".32" extension
  3297.          let File = FileName(File) - ".32"
  3298.          # And let Dir be the directory name
  3299.          let Dir = DirName(File)
  3300.      end
  3301.  
  3302.  See also:
  3303.      foreach, string functions, cmode, $
  3304.  
  3305. ?strings Read
  3306. ?Strings Read
  3307. ?Read
  3308.  
  3309.  The `Read' function read a line from the file chosen by the 
  3310.  `set input' function, strips the newline character and returns the
  3311.  resulting string. If the input is `stdin', the user will be
  3312.  prompted by a "?" and the program will stop until a non-null
  3313.  string is entered. This is most likely to be used in macros requiring
  3314.  some input during run time. The `Read()' function can be used to
  3315.  read numbers with the help of `scan()'. See the example below.
  3316.  
  3317.  `Read' can also be used to build vectors by taking one every n
  3318.  points. This can be done by two imbedded `for' loops.
  3319.  
  3320.  Note: The newline character is not passed to the string.
  3321.  
  3322.  Examples:
  3323.     # Read a string from stdin (the default)
  3324.     set input stdin
  3325.     let String = Read()
  3326.     # How to get a value out of a string: equivalent to vread()
  3327.     let value = scan(Read(), "%lf")
  3328.     # How to skip lines in a file
  3329.     # Read say file project/numbers.data
  3330.     set input project/numbers.data
  3331.     cmode
  3332.     for (i=1; i<=top; i++) {
  3333.         Line = Read()                            # Read one line
  3334.         X[i] = scan(Line, "%lf");                # get first column
  3335.         Y[i] = scan(Line, "%*lf %*lf %lf");        # get third column
  3336.         for (j=1; j<n; j++) {
  3337.             Line = Read()                        # Read n-1 lines
  3338.         }
  3339.     }
  3340.     fmode
  3341.     set input stdin
  3342.  
  3343.  See also:
  3344.      set input, math function scan, string functions, $
  3345.  
  3346. ?strings Scan
  3347. ?Scan
  3348.  
  3349.  `Scan("String, Format")' function returns a string as
  3350.  extracted from string "String" and according to string format 
  3351.  "Format". The format is built with the same rules `sscanf' uses.
  3352.  See man pages on `scanf(3)'. Note that the format must contain one
  3353.  active "%s" or "%[]" construction. An example might be of some help
  3354.  here, especially to show how to use `Scan' in conjunction with
  3355.  C-calculator mode defined strings. `Scan' is particularly helpful
  3356.  to extract parts of filenames. Recall that strings are defined by
  3357.  double quotes as in standard C.
  3358.  
  3359.  Knowing about the "%[ ]" scanf(3) construction might be useful at
  3360.  this point. Consider the following few examples: `"%[a-zA-Z]"'
  3361.  means to read the longest string matched so that it is composed of any
  3362.  letter; `"%[^0-9]"' means to read the longest string matched
  3363.  so that it is NOT composed of any digit; `"%[^_.]"' means to
  3364.  read the longest string matched so that it is not composed of
  3365.  characters `_' or `.'.
  3366.  
  3367.  Examples:
  3368.      # define a string called Testname
  3369.      let Testname = "dummy25.dat"
  3370.      # Read until a point is encountered
  3371.      let Base = Scan(Testname, "%[^.]"))
  3372.  
  3373.  See also:
  3374.      $, scan, string functions Read, DirName, FileName, C, cmode, quotes
  3375.  
  3376. ?system
  3377.  
  3378.  When called with arguments, the `system' command is equivalent to
  3379.  the `!' bang operator, so the remainder of the line will be given to a
  3380.  Bourne shell for execution. If `system' has no argument, a shell
  3381.  (depending on environment variable SHELL) will be started.
  3382.  
  3383.  Syntax:
  3384.      system "shell-commands(optional)"
  3385.  
  3386.  See also:
  3387.      environment, !, shell
  3388.  
  3389. ?then
  3390.  
  3391.  The `then' keyword is required in the fitting mode `if'
  3392.  constructions. Refer to the latter for details.
  3393.  
  3394. ?unalias
  3395.  
  3396.  The `unalias' command unaliases any alias previously assigned
  3397.  by the `alias' command.
  3398.  
  3399.  Syntax:
  3400.      unalias "alias_name"
  3401.  
  3402.  Examples:
  3403.      unalias date
  3404.      unalias gnuplot
  3405.  
  3406.  See also:
  3407.      &, alias, macro, unmacro, append, show
  3408.  
  3409. ?unlock
  3410.  
  3411.  The `unlock' command changes a constant into a variable and thus
  3412.  allows the user to change its value. This is particularly useful in
  3413.  functions and procedures needing to change the value of the `data'
  3414.  constant. Unlocking `data' gives the user complete freedom on the
  3415.  effective size of vectors. No check is done on `data'
  3416.  assignments, and therefore assigning a value to `data' that is
  3417.  superior to `samples' will result in a program crash. For this
  3418.  reason, it is always safer to change `data' using the `set
  3419.  data' command. It is not an error to unlock a variable. A warning
  3420.  message will be given though. However, trying to unlock something else
  3421.  than a constant or variable will result in an error.
  3422.  
  3423.  See also:
  3424.      lock, set data, set samples, cmode
  3425.  
  3426. ?unmacro
  3427.  
  3428.  The `unmacro' command is the counterpart of `macro'. It is
  3429.  used to undefine macros. As does `free', `unmacro' accepts the
  3430.  ``@all'' string in which case all the macros will be erased and freed
  3431.  from memory.
  3432.  
  3433.  Syntax:
  3434.      unmacro "macro-list" 
  3435.      unmacro @all
  3436.  
  3437.  Examples:
  3438.      unmacro myplot
  3439.      unmacro @all
  3440.  
  3441.  See also:
  3442.      alias, unalias, append, show
  3443.  
  3444. ?version
  3445.  
  3446.  The `version' command displays the version number and the
  3447.  welcoming message of FUDGIT.
  3448.  
  3449. ?vi
  3450. ?editor
  3451.  
  3452.  The command `vi' calls the editor. It is equivalent to
  3453.  `!vi filename'. Note that wild cards are also recognized and
  3454.  expanded.
  3455.  
  3456.  Syntax:
  3457.      vi "argument-list"
  3458.  
  3459.  Examples:
  3460.      vi file
  3461.      vi test.*
  3462.  
  3463.  See also:
  3464.      !, system, alias, shell
  3465.  
  3466. ?while
  3467. ?loop
  3468.  
  3469.  The `while' command allows the user to construct controlled loops
  3470.  on a series of operations. However, FUDGIT supports two kinds of
  3471.  `while' constructions, one in the fitting mode and the other in
  3472.  the C-calculator mode.
  3473.  
  3474. ?while cmode_style
  3475.  
  3476.  The C-calculator mode while construction has a syntax similar to
  3477.  that of standard C. In interactive mode, any new input line will be
  3478.  prompted with a ``n{... n\t'' where `n' stands for the nesting
  3479.  level and `\t' for a tab. Recall that "cmode-line-statement"
  3480.  means a string of semicolon separated C-calculator mode commands.
  3481.  
  3482.  Syntax:
  3483.      while ("conditions") "cmode-line-statement"
  3484.  
  3485.  or
  3486.  
  3487.      while ("conditions")
  3488.          "cmode-line-statement"
  3489.  
  3490.  or
  3491.      while ("conditions") {
  3492.           "cmode-statements"
  3493.      }
  3494.  
  3495.  Example:
  3496.      read file X:1 Y:2
  3497.      let x=12;sum1=0;sum2=0
  3498.      while (x++<=100) {
  3499.          sum1 += X[x]+Y[x]
  3500.          sum2 += X[x]^2 + Y[x]^2
  3501.      }
  3502.  
  3503.  See also:
  3504.      C, break, continue, cmode, for, func, proc, auto, math
  3505.  
  3506. ?while fmode_style
  3507.  
  3508.  The fitting mode `while' is very similar to the C-shell
  3509.  `while'. As for the `if' construction, the difference remains
  3510.  in a broader range of operators available to the conditional
  3511.  statement and the fact that the variable expansion operator `$' is
  3512.  not required.
  3513.  
  3514.  As for the `foreach' construction, a `end' keyword is
  3515.  required to indicate the end of the loop. Note that
  3516.  "fmode-statements" can also contain C-calculator mode commands
  3517.  (including cmode `while' loops!). Recall that the conditional
  3518.  statement is a C-calculator mode expression.
  3519.  
  3520.  Syntax:
  3521.      while("conditions")
  3522.           "fmode-statements"
  3523.      end
  3524.  
  3525.  See also:
  3526.      foreach, if, cmode
  3527.  
  3528. ?Credits
  3529.  
  3530.  Parts of FUDGIT were built from some existing facilities. I would
  3531.  like to give full credits for ideas or even segments of code that
  3532.  have been taken from the following sources.
  3533.  
  3534.    =>  For parts of the user interface:
  3535.  
  3536.     The help facility and the line editor were taken and adapted
  3537.     respectively from GNUPLOT, and READLINE. READLINE was written by
  3538.     Brian Fox. The help facility is originally from John D. Johnson.
  3539.  
  3540.    =>  For the C-calculator:
  3541.  
  3542.     The calculator is inspired from HOC calculator which was debugged
  3543.     and largely augmented to support vector algebra, memory management
  3544.     and extra operators. The source of the basic program is reproduced
  3545.     for educational purposes in "The Unix Programming Environment"
  3546.     by Brian W. Kernighan and Rob Pike, Prentice-Hall (1984).
  3547.  
  3548.    =>  For the fitting functions:
  3549.  
  3550.     Some of the included fitting routines are based on the algorithms
  3551.     found in chapter 14 of "Numerical Recipes in C" by W. H. Press,
  3552.     B. P. Flannery, S. A. Teukolsky and W. T. Vettering, Cambridge
  3553.     University Press (1988), of which some were in turn adapted from
  3554.     LINPACK. I had to adapt all the algorithms to include elegant error
  3555.     recovery and to perform all calculations on vectors outside the
  3556.     fitting loops, since their implementation would not permit the use
  3557.     of run-time user selectable functions. FUDGIT would not have been
  3558.     possible without the valuable help of that book. Since I strongly
  3559.     recommand that you have a copy of a fitting book, I strongly
  3560.     suggest you have a copy of this one. Not only this book will
  3561.     describe all the methods used in FUDGIT but it will also give you
  3562.     unvaluable insights to get to the state of the art of fitting.
  3563.     These routines are copyrighted and cannot be separated from FUDGIT.
  3564.  
  3565.     Copyright (C) 1987, 1988 Numerical Recipes Software. Reproduced by
  3566.     permission from the book "Numerical Recipes: The Art of
  3567.     Scientific Computing" published by Cambridge University Press.
  3568.  
  3569.    =>  For the fft routine:
  3570.     
  3571.     The fft routine was first derived from an original Pascal version
  3572.     written in "Simple Calculations with Complex Numbers" by David
  3573.     Clark in DDJ 10/84 and then translated to C by R. Hellman
  3574.     (02/21/86). I rewrote the C version to use vectors of alternated
  3575.     double real and imaginary instead of the original (slow) vector of
  3576.     pointers to complex structures. I also merged all functions in one
  3577.     to prevent unnecessary function calls. I was astonished to see that
  3578.     the resulting version was almost identical to the one found in
  3579.     Numerical Recipes with the exception of a trigonometric recursion.
  3580.     In conclusion, given an algorithm, I think that is is a hard task
  3581.     to try to write a code much better than the one found there. This
  3582.     is normal since the space of code possibilities gets narrower as
  3583.     the constraints (optimization) acting on an implementation in a
  3584.     given language are increased. The one included is from N.R. which
  3585.     was adapted from N. Brenner.
  3586.  
  3587.     Copyright (C) 1987, 1988 Numerical Recipes Software. Reproduced by
  3588.     permission from the book "Numerical Recipes: The Art of
  3589.     Scientific Computing" published by Cambridge University Press.
  3590.  
  3591.    =>  For the help file:
  3592.  
  3593.     I would like to thank Ross Thompson for proofreading part of the
  3594.     documentation and also for giving me constructive feedback in
  3595.     course of the program development.
  3596.  
  3597.    =>  For the IRIX supported dynamic loading package:
  3598.  
  3599.     The `dl' Dynamic Loading package is from Jack Jansen
  3600.     <Jack.Jansen@cwi.nl> from the "Centrum voor Wiskunde en
  3601.     Informatica". This package only works on IRIX for now.
  3602.  
  3603.    =>  For the SUNOS, ULTRIX supported dynamic loading package:
  3604.  
  3605.     The implementation of `dl' for SUNOS and ULTRIX is from Guido
  3606.     van Rossum <guido@cwi.nl> from the "Centrum voor Wiskunde en
  3607.     Informatica". I modified part of it to allow multiple routine
  3608.     loading from the same object. The other part of the puzzle is the
  3609.     `dld' loader from Wilson Ho <how@cs.ucdavis.edu> which is based
  3610.     on GNU ld(1) and is under GNU license.
  3611.  
  3612.    =>  For compilers not having `alloca()':
  3613.  
  3614.     The included public domain version of alloca is from D. A. Gwyn.
  3615.  
  3616.    =>  For systems not having `putenv()':
  3617.  
  3618.     The version of putenv was adapted from Dave Taylor's elm who
  3619.     adapted it from cnews.
  3620.  
  3621.    =>  For a lot of ideas:
  3622.  
  3623.     Many thanks to Steve Hornes for stimulating e-mail discussions.
  3624.     Steve is responsible for the idea of implementing dynamic loading
  3625.     in the final development of FUDGIT.
  3626.  
  3627.    =>  For the port to linux:
  3628.  
  3629.     The port to linux was made by Thomas Koenig
  3630.     <ig25@rz.uni-karlsruhe.de>.  Thanks a lot Thomas!
  3631.  
  3632.    =>  For the rest of the code:
  3633.  
  3634.     Copyright (C) 1993   Martin-D. Lacasse
  3635.   
  3636.     See the Copyrights file for more detail, or the `README' help topic.
  3637.  
  3638.     Permission to use, copy, and distribute this software and its
  3639.     documentation for any peaceful purpose and without fee is hereby
  3640.     granted, provided that the above notices appear in all copies and
  3641.     that both those notices and this permission notice appear in
  3642.     supporting documentation. No part of this can be used for commercial
  3643.     purposes.
  3644.  
  3645.     Send bugs, comments or suggestions to
  3646.  
  3647.             <isaac@physics.mcgill.ca>.
  3648.  
  3649.  Disclaimer:
  3650.  
  3651.     This software is provided "as is" without express or implied warranty.
  3652.  
  3653.  
  3654. ?README
  3655.  
  3656.  The eclectic nature of FUDGIT makes it a borderline program.
  3657.  I would like to include the following comments on copyrights.
  3658.  
  3659.  Some Definitions
  3660.  ================
  3661.  
  3662.  Scientific Community: By "Scientific Community" is meant the whole of
  3663.  researchers in industries, universities and government agencies,
  3664.  students as well as individuals making research on their own.
  3665.  
  3666.  Software Developers: By "Software Developers" is meant all the
  3667.  people writing or selling softwares with commercial purposes.
  3668.  
  3669.  Publicly Available Sources: By "Publicly Available Sources" is meant
  3670.  the pool of all source codes, algorithms and ideas that can be found
  3671.  in publicly available scientific journals, publicly available
  3672.  educational books, public domain source code, algorithms and ideas, or
  3673.  source code, algorithms and ideas aimed at helping the Scientific
  3674.  Community. That is, Publicly Available Sources are publicly available
  3675.  material that can be part of higher education programs.
  3676.  
  3677.  Progressive Copyrights
  3678.  ======================
  3679.  
  3680.  People involved in the Scientific Community need access to the most
  3681.  recent developments to continue their own research. At the same time,
  3682.  the same people share their most recent discoveries to the rest of the
  3683.  Scientific Community. Standard Copyrights apply to the commercial
  3684.  applications of their results.
  3685.  
  3686.  Source code raised the problem that for the first time, the research
  3687.  product is deeply involved in the research process. For the first
  3688.  time, restrictions are being put on a fundamental research tool. This
  3689.  is why the traditional way of thinking about Copyrights is obsolete.
  3690.  
  3691.  Copyrights were implemented with the idea of protecting the commercial
  3692.  interests of the owner. Thus, standard Copyrights give the owner the
  3693.  exclusive rights of having commercial applications of his/her
  3694.  implementation of an idea. However, some copyrights are much too
  3695.  restrictive concerning scientific applications. Sometimes, old ideas
  3696.  suddenly become protected because a group of Software Developers
  3697.  claim Copyrights for pieces of code that freely existed for a long
  3698.  time already, or are the straightforward representation of a given idea
  3699.  in a given language. This simply does not make sense, and for this
  3700.  reason, more realistic copyright procedures are required.
  3701.  
  3702.  Progressive Copyrights should give the author the full commercial
  3703.  rights but leaves the Scientific Community the right to use the source
  3704.  code, the algorithms and the ideas for their own purposes. It does not
  3705.  allow Software Developers to use the source code for commercial
  3706.  applications, but they are free to use the ideas included in the
  3707.  source code. In other words, Software Developers cannot make money
  3708.  from the hard work someone else did. If they want to do so, they have
  3709.  to agree with the people owning the Progressive Copyrights.
  3710.  
  3711.  Progressive Copyrights should apply to all Publicly Available Sources.
  3712.  From the moment a source code is published and becomes publicly
  3713.  available, the people from the whole Scientific Community have the
  3714.  right to use it for their own purposes.
  3715.  
  3716.  A small group of Software Developers cannot claim Copyrights for
  3717.  source code, algorithms and ideas that have been around for a while,
  3718.  tested, improved, and commented by the whole Scientific Community.
  3719.  
  3720.  A University student cannot start in life with a Bachelor degree and
  3721.  have part of it copyrighted!
  3722.  
  3723.  Progressive Copyrights are more a way of thinking than a legal
  3724.  matter. I just hope that this way of thinking will spread in the
  3725.  Scientific Community. After all, Progressive Copyrights are just
  3726.  common sense! Despite Software Developers lobby.
  3727.  
  3728.